Jump to content

[SOLVED] MM_jumpMenu and PHP


sd9sd

Recommended Posts

Hi,

 

I've got some html for a combobox:

<td><form name="form1"><div align="center">
          <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
            <option>tag (23)</option>
            <option>tag (3)</option>
            <option>By Title</option>
            <option selected>Show All (92)</option>
          </select>
        </div>
      </form></td>

I have a php file which echoes the html file to display it.

I'm using this code for the php file to call itself:

$path = empty($_SERVER['PATH_INFO'])?$_SERVER['PHP_SELF']:$_SERVER['PATH_INFO'];

 

What I need is that when an option in the combobox is chosen, the option chosen should appear in the addressbar as a query string OR it should be available as a $_POST variable so that my php file should be able to capture it as either $_GET['id'] or $_POST['id']

 

Currently what's happening is: when an option is selected the php file calls itself, but the option chosen gets added to the address and it gets shown like www.site.com/optionChosen.

I don't have a separate function to handle the MM_jumpMenu, but when I choose the option, how can I avoid it appearing in the addressbar and to capture it as a GET or POST?

Link to comment
https://forums.phpfreaks.com/topic/115179-solved-mm_jumpmenu-and-php/
Share on other sites

Got it myself...the javascript has to be configured to send a query to php

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  var tagValue=selObj.options[selObj.selectedIndex].value;
  var stringCarryingQuery=tagValue.substring(0,tagValue.indexOf(" ("));
  var outputString=targ+".location='"+"a.php?tagSelection="+stringCarryingQuery+"'";
  //document.write(outputString);
  eval(outputString);
  //if (restore) selObj.selectedIndex=0;
}

//-->
</script>

for

<select name="tagSelection" onChange="MM_jumpMenu('self',this,0)">>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.