Page 1 of 1

Passing two variables to a javascript function

Posted: Sun Sep 26, 2010 6:52 pm
by PastorHank
If I'm not phrasing this correctly so please forgive me

I have a drop down list on my form that when I make a selection it calls a function and passes the value to it, everything works fine and it does exactly what I want it to do.

What I would like to add though is a radio button group that has another set of values in it (such as - active, inactive, for sale). I want the user to be able to select one of those options and then when the drop down list is selected have both values passed to the function so my select statement can use both.

I'm familiar with creating a multiple _GET, and I understand that I can add the first variable as parameter in the function but how do I get the program to read the value of the radio button group?

If someone could please point me to some examples of such a thing, I'd greatly appreciate it.

Thank you

Re: Passing two variables to a javascript function

Posted: Mon Sep 27, 2010 5:24 am
by DigitalMind
just some hints...

Code: Select all

<form action="action.php" name="form1">
<input type="text" name="field1">

<input type="radio" name="field2" value="value1"> 1<br>
<input type="radio" name="field2" value="value2"> 2<br>
<input type="radio" name="field2" value="value3"> 3<br>
<input type="radio" name="field2" value="value4"> 4<br>
</form>
in order to reach form elements use:
document.form1.field1
document.form1.field2[]
like x = document.form1.field1.value or
y = -1;
for (i = 0; i < document.form1.field2.length; i++) {
if (document.form1.field2.checked) y = i;
}

Re: Passing two variables to a javascript function

Posted: Mon Sep 27, 2010 6:22 am
by PastorHank
Thank you