Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Checkboxes


Message #1 by "Julian Sinclair" <j.sinclair@f...> on Tue, 14 Aug 2001 16:54:06 +0100
This line: document.search_form.elements[newIndex].checked == true
should be : document.search_form.elements[newIndex].checked = true


Regards

Joe Fawcett



>From: "Julian Sinclair" <j.sinclair@f...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] Checkboxes
>Date: Tue, 14 Aug 2001 16:54:06 +0100
>
>Hi all,
>
>need a bit of help here.
>
>I have a form where the user can select one or more of a number of criteria
>to search by. By ticking a check box the corresponding criteria is added to
>the search string.
>
>What I would like to do is if a user instead of ticking the checkbox just
>types directly into the text box the checkbox is ticked automatically. I
>have tried the following function but this does not put a tick in the
>checkbox. Can anyone tell me what I need to do ?
>
>The alerts are just there to check that the correct box was being selected
>from the array (it is) and the array is there to match checkbox/textarea
>pairs.
>
>
>//Function to automatically tick check box if text area is selected.
>function tickBox(index)
>{
>	var tickIndex = new Array(0,3,6);
>	var newIndex = tickIndex[index];
>	alert(document.search_form.elements[newIndex].name);
>	document.search_form.elements[newIndex].checked == true
>	alert(document.search_form.elements[newIndex].checked);
>}
>
>Julan

  Return to Index