Jump to content

PHP Passing Data from URL


deathdeyfer2002

Recommended Posts

All-

I am trying to pull data from my url.

 

Here is my URL: http://index.php?type=ALL&size=ALL

 

I'm using Type to determine what to display and size to determine how many to show before going to a new page.

 

I have also created a drop down menu:

 

 

<FORM ACTION="">

<select name="jumpto" onChange='window.location.href= this.form.jumpto.options[this.form.jumpto.selectedIndex].value'>

<option selected># Per Page</option>

<option value ="index.php?type=&size=ALL">All</option>

<option value="index.php?">100</option>

<option value="index.php">50</option>

<option value="index.php">25</option>

</select>

</FORM>

 

Now what I want to do is take whatever "type" is currently being viewed and only change the size attribute.  So If im on http://index.php?type=A&size=ALL and I select 25 from the drop down, I want the corresponding url to be http://index.php?type=A&size=25.

 

I have been trying many different things and one idea I had was to store the variable in javascript.

 

Here is the code for that:

<script type="text/javascript">

var type = "<?echo $_GET['type']; ?>";

//document.write(type);

</script>

 

Can't quite figure how how to make that work.  Anyone have any ideas? 

 

 

Please Help!!

Link to comment
https://forums.phpfreaks.com/topic/182530-php-passing-data-from-url/
Share on other sites

Looks like you were on the right track. Try this:

 

<FORM ACTION="">
<select name="jumpto" onChange='window.location.href= this.form.jumpto.options[this.form.jumpto.selectedIndex].value'>
<option selected># Per Page</option>
<option value ="index.php?type=<?php echo $_GET['type']; ?>&size=ALL">All</option>
<option value="index.php?type=<?php echo $_GET['type']; ?>&size=100">100</option>
<option value="index.php?type=<?php echo $_GET['type']; ?>&size=50">50</option>
<option value="index.phptype=<?php echo $_GET['type']; ?>&size=25">25</option>
</select>
</FORM>

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.