Passing two variables to a javascript function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Passing two variables to a javascript function

Post 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
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Passing two variables to a javascript function

Post 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;
}
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Re: Passing two variables to a javascript function

Post by PastorHank »

Thank you
Post Reply