Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to submit multiple key value pa 1

Status
Not open for further replies.

SirCharles

Programmer
Jun 10, 2002
212
US
How to submit multiple key value pairs while only selecting one item from a list? Ie. I need multiple values for one selection.
 
In a select box? If you want Area Code and Phone Number then

<option value=&quot;123,4567890&quot;>Fake Phone Number</option>

Use Javascript's split function:

values = obj.value.split(&quot;,&quot;)

In this example, values[0] = 123 and values[1] = 4567890
 
Please help me with syntax:

<script language=&quot;JavaScript&quot;>
function setSubDir(value) {

what goes here? ie. what obj to use?
values = obj.value.split(&quot;,&quot;);
values = document.form2.values.split(&quot;,&quot;); // this work?

window.location=&quot;path/to/barscript.pl?&quot;+&quot;param1=&quot;+values[0]+&quot;&param2=&quot;+values[1];
}
</script>
<FORM action=&quot;path/to/bar2script&quot; method=GET name=form2>

<select name=&quot;progName&quot;>
<option value=&quot;param1, app1&quot;>App 1</option>
<option value=&quot;param2, app2&quot;>App 2</option>
<option value=&quot;param3, app3.pl&quot;>App 3</option>
</select>
<INPUT type=button name=&quot;buttona&quot; value=&quot;testing Button&quot; onClick=&quot;setSubDir(----what goes here?----);&quot; />
<INPUT class=go type=submit name=&quot;action&quot; value=&quot;Run&quot;&quot;>
</form>
 
the line should read:

values = document.form2.projName.value.split(&quot;,&quot;)

then values[0] is paramX and values[1] is appX

Enjoy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top