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

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.