Automate undisabled a “submit button”?

Thread Solved

Join Date: Mar 2008
Posts: 5
Reputation: Hercf is an unknown quantity at this point 
Solved Threads: 0
Hercf Hercf is offline Offline
Newbie Poster

Automate undisabled a “submit button”?

 
0
  #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 8:01 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: Automate undisabled a “submit button”?

 
0
  #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. }

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

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

Re: Automate undisabled a “submit button”?

 
0
  #3
Apr 30th, 2008
cmhamton has provided the solution - but just to expand:
So as to open the function to any form and any form objects:

  1. function toggleObj(frmFld,frmBtn)
  2. {
  3. //frmFld = the Form Field to check for value
  4. //frmBtn = the Form Button to disable/enable
  5.  
  6. if(frmFld.value.length>0)
  7. {
  8. frmBtn.disabled=false;
  9. }
  10. else
  11. {
  12. frmBtn.disabled=true;
  13. }
  14. }

sorry - haven't actually tested this...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the ColdFusion Forum


Views: 2663 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ColdFusion
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC