Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

[Resolved] Querystring question

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

kwan

Established Member
Impact
19
querystring question

I'm trying to use a simple html form, but after submitting the existing variables are replaced.

So if I submit a form on a page like index.php?page=1 with a form
<form><input name="chapter">1</input></form>

it sends me to index.php?chapter=1 while I need index.php?page=1&chapter=1.

I know I could put the page variable in the form, but there should be an easier way (I gave 1 variable as an example, but there could be more).
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
what is the actual code for the form you are using. Ensure you have set the action as index.php?page=1.

Alternatively you could set the page number as a hidden field.
 
0
•••
This is the code

Code:
<form method="get" action="index.php?page=1">
  <select name="chapter" onchange="this.form.submit();">
    <option value="1">1</option>
    <option value="2">2</option>
  </select>
</form>
I tried using both post and get. And you're right about the hidden field, but like I said there could be more than one parameter and it seems more obvious to keep them in the url than create a field for each one.

Normally I would use a session to store the page value, but I want it in the URL for SEO reasons.

peter@flexiwebhost said:
what is the actual code for the form you are using. Ensure you have set the action as index.php?page=1.

Alternatively you could set the page number as a hidden field.
 
0
•••
Try stopping the javascript and see if it works. There is nothing wrong with the way you are doing it so it may be the javascript stripping the variable from the action address.
 
1
•••
That didn't help either. It's probably being stripped by the browser to prevent XSS or something. I added them in hidden fields like you said and that works.

Thanks anyways for the suggestions.


peter@flexiwebhost said:
Try stopping the javascript and see if it works. There is nothing wrong with the way you are doing it so it may be the javascript stripping the variable from the action address.
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back