Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Want to send multiple selects as one input.

    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
    something.com/?keyword="x+y"

    How would I go about doing this?

    I tried doing this but it didn't work:
    Code:
    <?php $key=""; ?>
    <script>
    function h(dd) 
    {
    	var idx = dd.selectedIndex;
      var val = dd[idx].label;
    	return "\"" + val + "\"";
    }
    </script>
    
      <tr>
      	<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>
    					<option>אונדה</option>
    				</select>
            <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" />
          </form>
        </td>
      </tr>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Hopefully this should move you forward:-


    Code:
    <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>
    <br>
    <select name = "sel2" id = "sel2" onchange = "getValue()">
    <option value = "x">x</option>
    <option value = "y">y</option>
    <option value = "z">z</option>
    </select>
    </form>
    
    
    <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);
    }
    </script>

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •