Disabling/Enabling form elements

This is a discussion on "Disabling/Enabling form elements" within the JavaScript Forum section. This forum, and the thread "Disabling/Enabling form elements are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2006, 14:05
New Member
Join Date: Aug 2004
Location: United Kingdom
Age: 29
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Disabling/Enabling form elements

Hi i have a form featuring 2 images as input types (buy and requote). When you enter the page requote is disabled and greyed out (switched off) and i have a checkbox that switches the buy button off (i.e. disables it and displays a greyed out version of it) and enables requote. When the checkbox is unchecked it should switch back again to its original state.

Here is my function

Code: Select all
 
<script type="text/javascript">
   function excludeMedCon()
   {
     document.getElementById("buy").disabled='true'
     document.getElementById("requote").disabled='false'
     document.getElementById("buy").src="images/buy_now_disabled.gif"
     document.getElementById("requote").src="images/button_requote.gif"
   }
 
   function noexcludeMedCon()
   {
    document.getElementById("requote").disabled='true'
    document.getElementById("buy").disabled='false'
    document.getElementById("buy").src="images/buy_now.gif"
    document.getElementById("requote").src="images/button_requote_disabled.gif"
   }
  </script>
Here is the code that calls the function from the checkbox being clicked:

Code: Select all
 
onClick="if (this.checked) { excludeMedCon() } else { noexcludeMedCon() }"
My images are switching fine and the buttons are being disabled fine, but they are not being re-enabled. I though the syntax to re-enable a disabled form item was just disabled='false' but obviosuly i am wrong. Any ideas as i am stumped?


Thanks in advance.
Reply With Quote

  #2 (permalink)  
Old Oct 18th, 2006, 21:51
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Disabling/Enabling form elements

Because true and false are boolean values, you should not have quotes around them.

You should also get in the habit of terminating all your lines with a semicolon.
Reply With Quote
Reply

Tags
input type image

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crazy disabling buttons 1840dsgn Flash & Multimedia Forum 1 Nov 1st, 2007 22:46
[SOLVED] Problem accessing specific form elements Sagaris JavaScript Forum 4 Sep 23rd, 2007 11:52
Drop down form elements 1840dsgn Web Page Design 3 Sep 4th, 2007 19:09
Simple form elements question! jtotheb PHP Forum 3 Jul 18th, 2007 14:54
download browser screenshots, form elements and buttons neckcns Graphics and 3D 0 Dec 23rd, 2005 16:24


All times are GMT. The time now is 05:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43