gvimercati
08-29-2003, 05:54 AM
hello, im a newy to this forum... and to javascript for that matter, my situation is...:
i have 20 or checkboxes in a form, the form Posts to itself because it needs server side validation, i need to make sure that if the checkbox is ticked and the form is submitted, the value of the checkbox changes b4 the submission... the way i am doing this is with am onChange='Invert(this.name);'
function Invert(inputName)
{
//doco below doesn't output the number... only the string
doco = "document.form."+inputName+".value";
if (doco== 1)
doco= 0;
else
doco= 1;
}
im trying to reuse the code as much as possible or else i know that i could simply write 20 if statements... there has to be a reusable way... can someone shed some light...
in simpler terms, i need 'doco' to give the value not the string..
im open to all suggestions.. or if there is another way of doing this... i'm all ears
thanks for the patience...
i have 20 or checkboxes in a form, the form Posts to itself because it needs server side validation, i need to make sure that if the checkbox is ticked and the form is submitted, the value of the checkbox changes b4 the submission... the way i am doing this is with am onChange='Invert(this.name);'
function Invert(inputName)
{
//doco below doesn't output the number... only the string
doco = "document.form."+inputName+".value";
if (doco== 1)
doco= 0;
else
doco= 1;
}
im trying to reuse the code as much as possible or else i know that i could simply write 20 if statements... there has to be a reusable way... can someone shed some light...
in simpler terms, i need 'doco' to give the value not the string..
im open to all suggestions.. or if there is another way of doing this... i'm all ears
thanks for the patience...