View Full Version : Want to send multiple selects as one input.

01-18-2009, 08:27 PM
I have two drop down menus that each have different things in them. I choose both of them. When I submit "x" in one menu and "y" in another I want it to work so that the url will be

How would I go about doing this?

I tried doing this but it didn't work:

<?php $key=""; ?>
function h(dd)
var idx = dd.selectedIndex;
var val = dd[idx].label;
return "\"" + val + "\"";

<td span="2">
<form action="<?php echo $mm_action_url."index.php" ?>" method="get">
<select name="keyword" onChange="h(this);">
<option label="Select Car">Select Car</option>
<option label="אאודי">אאודי</option>
<input class="button" type="submit" name="Search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>" />
<input type="hidden" name="keyword" value="<?php echo $key;?>" />
<input type="hidden" name="Itemid" value="<?php echo intval(@$_REQUEST['Itemid']) ?>" />
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="page" value="shop.browse" />

Philip M
01-18-2009, 09:05 PM
Hopefully this should move you forward:-

<form name = "myform">
<select name = "sel1" id = "sel1" onchange = "getValue()">
<option value = "a">a</option>
<option value = "b">b</option>
<option value = "c">c</option>
<select name = "sel2" id = "sel2" onchange = "getValue()">
<option value = "x">x</option>
<option value = "y">y</option>
<option value = "z">z</option>

<script type = "text/javascript">
function getValue() {
var obj1 = document.getElementById("sel1");
var p1 = obj1.value;
var obj2 = document.getElementById("sel2");
var p2 = obj2.value;
var keyword = p1 + "+" + p2;
alert (keyword);

Before a man speaks it is safe to assume that he is a fool. After he speaks it is seldom necessary to assume.
H.L. Mencken 1880-1956, American Editor, Author, Critic, Humorist