PDA

View Full Version : cookie's and checkboxs???


JackFruit3D
11-12-2002, 02:55 AM
I have several checkboxes... ie.

<input type="checkbox" name="PickMe1" onclick="AddCookie('146', 'Red')">
<input type="checkbox" name="PickMe2" onclick="AddCookie('146', 'Blue')">

and the following script to run

function AddCookie(id, name)
if document.all.PickMe????????.checked then
document.cookie = name "=" & id
end if
end function

i was wondering (through my lack of knownledge) how i could use the id sent with the script to check if that check box is checked???

glenngv
11-12-2002, 03:11 AM
<input type="checkbox" name="PickMe1" onclick="AddCookie(this,'146', 'Red')">
<input type="checkbox" name="PickMe2" onclick="AddCookie(this,'146', 'Blue')">


<script language="javascript">
function AddCookie(objChk,id, name){
if (objChk.checked) document.cookie = name + " = " + escape(id)
}
</script>


...or you can retain your function and do it like this:

<input type="checkbox" name="PickMe1" onclick="if (this.checked) AddCookie('146', 'Red')">
<input type="checkbox" name="PickMe2" onclick="if (this.checked) AddCookie('146', 'Blue')">


you may want to search for cookie scripts, you can find it anywhere on the net.

JackFruit3D
11-12-2002, 03:28 AM
Does the same script work for VBScript???

glenngv
11-12-2002, 03:36 AM
that will work on IE and all javascript-aware browsers for that matter.
btw, why do you want it VBScript?

JackFruit3D
11-12-2002, 07:59 PM
dunno know really
just decided that i'd be differcult and use VBScripting