Jump to content

Pass Javascript variable to PHP page


AshleyByrom

Recommended Posts

Okay so I have set up a little skins function on my website that works fine.

 

There is a jump menu with two values inside it. The values are blue and pink.

 

When blue is selected you are sent to executeBlue.php

When pink is selected you are sent to executePink.php

 

the execute pages then need to change the skin (which they do) and then send you BACK to the page you were viewing. That is where I am stuck. Using the following code I have managed to store the page name inside a javascript variable.

 

<script language="javascript">
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
</script>

 

so sPage stores the page name. I would like to link to each of the execute files so instead of sending you to executeBlue.php you are sent to executeBlue.php?page=sPage

 

How could this be done?

 

<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
            <option>Skin</option>
            <option value="executeBlueSkin.php?page=">Blue</option>
            <option value="executePinkSkin.php">Pink</option>
          </select>

 

there's my jump menu code if it helps.

Link to comment
https://forums.phpfreaks.com/topic/166964-pass-javascript-variable-to-php-page/
Share on other sites

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.