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
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)">>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.