User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 332,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,162 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 544 | Replies: 2
Reply
Join Date: Mar 2008
Posts: 2
Reputation: Hercf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Hercf Hercf is offline Offline
Newbie Poster

Automate undisabled a “submit button”?

  #1  
Apr 5th, 2008
Help!
Hi, everbody!
I have this problem:
There is a “textbox” and a “submit” button.
“Submit button” is disabled until something is written within “text box”. I am not able to do this switch. Could anybody help me?
Here you are the code:

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5. </head>
  6.  
  7. <body>
  8. <cfform name="form1" id="form1" method="post" action="">
  9. <cfinput type="text" name="Text" id="Text">
  10. <cfinput type="submit" name="submit" disabled="disabled" id="submit" value="Submit">
  11. </cfform>
  12. </body>
  13. </html>
Thank you!
Last edited by peter_budo : Apr 7th, 2008 at 7:01 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 32
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
cmhampton cmhampton is offline Offline
Light Poster

Re: Automate undisabled a “submit button”?

  #2  
Apr 10th, 2008
You need to use a javascript function for this:

  1. function ChangeButtonStatus()
  2. {
  3. if (document.getElementById("Text").value.length > 0)
  4. {
  5. document.getElementById("submit").disabled = false;
  6. }
  7. else
  8. {
  9. document.getElementById("submit").disabled = true;
  10. }
  11. }
  12.  

Then in your form, add an OnBlur event to the textbox:

  1. <cfinput type="text" name="Text" id="Text" OnBlur="ChangeButtonStatus()">
Reply With Quote  
Join Date: Oct 2005
Posts: 8
Reputation: jamba is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jamba jamba is offline Offline
Newbie Poster

Re: Automate undisabled a “submit button”?

  #3  
16 Days Ago
cmhamton has provided the solution - but just to expand:
So as to open the function to any form and any form objects:

function toggleObj(frmFld,frmBtn) 
{
//frmFld = the Form Field to check for value
//frmBtn = the Form Button to disable/enable

if(frmFld.value.length>0)
{
frmBtn.disabled=false;
}
else
{
frmBtn.disabled=true;
}
}

sorry - haven't actually tested this...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ColdFusion Marketplace
Thread Tools Display Modes

Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 12:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC