checkbox associated with text box

Results 1 to 3 of 3

Thread: checkbox associated with text box

  1. #1
    Join Date
    Dec 1969

    Default checkbox associated with text box

    This is supposed to be very easy to do but I can&#039;t figure out how come this code don&#039;t work :<BR>I would like to active my edit box and the CheckBox is Checked, otherwise, disabled the edit box if the check box isnt checked.<BR><BR>Here&#039;s the code:<BR>function CheckTextBoxMode( ) {<BR><BR>if ( document.ExecutiveForm.checkTargetWage.value == "on" )<BR> {<BR> document.ExecutiveForm.targetPercWage.disabled= false<BR> }<BR>else <BR> {<BR> document.ExecutiveForm.targetPercWage.disabled= true<BR> }<BR>}<BR><BR>&#060;! Showing Target % Wage form part&#062;<BR><BR>&#060;INPUT type="checkbox" id=checkTargetWage name=checkTargetWage OnClick="CheckTextBoxMode( )"&#062;<BR><BR>Target Percentage Wage: <BR>&#060;INPUT type="text" style="width:50px" id=targetPercWage name=targetPercWage OnMouseOut="this.value= &#039;&#039;"&#062; %<BR><BR>=========<BR>Only the first time, the text box will be set to Disabled (true) , ... but never came back to false or true ... it&#039;s disabled the first time, and STAY disabled for all times<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: checkbox associated with text box

    Change your function to this. <BR><BR>function CheckTextBoxMode( )<BR>{<BR> if (document.ExecutiveForm.checkTargetWage.checked)<B R> {<BR> document.ExecutiveForm.targetPercWage.disabled=fal se<BR> }<BR> else<BR> {<BR> document.ExecutiveForm.targetPercWage.disabled=tru e; <BR> } <BR>}<BR><BR>You may also want to set the text box to be disabled off the start like the following line.<BR>&#060;INPUT type="text" style="width:50px" id=targetPercWage name=targetPercWage disabled&#062;

  3. #3
    cool Guest

    Default RE: checkbox associated with text box

    thanks a lot it&#039;s now working! :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts