473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to change a variable in a URL?

I am trying to allow users to toggle between various metrics that I am covering and having that information update on the page.

The way that my data is interpreted on my page is by using variable in the URL. The standard structure is: /frontend.php?p=502&s=56&y=2010

Where p = player id
s = statistic id
and y = year

I am trying to implement a drop down selection list on the page where users can change the statistic.

Here is my code. Any help would be very appreciated!

Expand|Select|Wrap|Line Numbers
  1. <form action="/frontend.php?p=<?= $player_id; ?>&" method="get" >
  2. <select id="stat" name="s" style="width: 215px">
  3. <option>-- Statistic --</option>
  4. <?php foreach( getStatistics() as $id => $name ){ ?>
  5.   <option value="<?= $id; ?>"><?= $name; ?></option>
  6. <?php } ?>
  7. </select>
  8. <input type="submit" value="Graph" style="height: 25px; width: 200px">
  9. </form>
  10.  
When this form is submitted I only get http://tyrone.pae.me/frontend.php?s=4 this URL to show. I need to be able to maintain the 'p' value and the 'y' value but alter the 's' value.
Sep 23 '10 #1

✓ answered by dlite922

create hidden input fields and put in the values you want to preserve.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="hidden" name="p" value="<?php echo $_GET['p'];?>" 
  3.  
  4.  
Same for Y and S.

If there's a hidden field for S, then an actual select field for S, then the value from the S field will be counted because it comes later and gets overwritten.

Dan

1 1365
dlite922
1,584 Expert 1GB
create hidden input fields and put in the values you want to preserve.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="hidden" name="p" value="<?php echo $_GET['p'];?>" 
  3.  
  4.  
Same for Y and S.

If there's a hidden field for S, then an actual select field for S, then the value from the S field will be counted because it comes later and gets overwritten.

Dan
Sep 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jack | last post by:
Hello, <%@ Language=VBScript %> <% dim a dim b a=11 b="11" if a=b then Response.Write "a=b" end if
2
by: Varad | last post by:
Can I change the value of a variable at runtime using the command window? I thought I was able to do it in VB 6.0 on VStudio 6.0? Is the same thing available in .net? Pls help. I hate to have to...
1
by: kuba | last post by:
hello i've problem. here is sample code: <SCRIPT LANGUAGE="JavaScript"> <!-- //var city = NewYork;
1
by: javiercubre | last post by:
Hello, I'm currently assigned to do a DS model, with the client acessing and changing a value defined in server and i was told to use the select function to do it, but i'can't understand why....
2
by: tony wong | last post by:
i use the following script (from textbook) to restrict 160 character in Message_cont textbox. how can i to change the number of character to 70 if any double bytes character detected in the...
6
by: Allen | last post by:
In C++, we can do it like this: void Square(int& value) { value *= value; } How can I do it in Java? I try the following method, but it does not work.
5
by: cty0000 | last post by:
I need to set several variable (can be different type) by sub function.. I don't know the count of variable and type, so i used object type and parameter list like below source.. After setData...
3
by: julytweety | last post by:
Hello Everyone, I have a javascript file, which has some variables set. I wanted to change the existing variable names dynamically. For example, In my file i have my variable prefix as S_ (S...
4
by: padew | last post by:
<?php $var01='test1'; $var02='test2'; ?> <script type="text/javascript"> -1 var a= '<?php echo $var01 ?>'; var b= '<?php echo $var02 ?>'; .... many other variables
1
by: Napcrisis | last post by:
Hi i need to change a variables' type from String to Int in managed c++ but dunno how to. Do any1 know how i can do this? Regards Tom
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.