Tom Turner
Tom Turner

Reputation: 43

HTML Form GET method with previous get parameters

I have a form on a page with get parameters:
index.php?PageID=12

I then have a multiple forms on that page which build up the page details as the user selects the details.

My problem is when the form is posted the Get overwrites other get parameters.

I can use post but then can only post the information back once as the post values are wiped when the next form is submitted;

the idea is the forms build up a address as such;

  1. ?PageID=12
  2. ?PageID=12&Section=48
  3. ?PageID=12&Section=48&Event=1456

and so on as the user selects more items.

Thanks for your help.

Upvotes: 4

Views: 3737

Answers (3)

Salman Arshad
Salman Arshad

Reputation: 272106

For forms with method=get the query string parameters specified in action attribute are ignored. Add such parameters as hidden form fields:

<form action="index.php" method="get">
<input type="hidden" name="PageID"  value="12">
<input type="hidden" name="Section" value="48">
<input type="hidden" name="Event"   value="1456">
</form>

You can use server-side script or JavaScript to add the query string parameters as hidden form fields.

Upvotes: 3

Harsh Chunara
Harsh Chunara

Reputation: 585

you can use the below code in which you can initialize the parameter that already required to post

<form action="index.php" method="get">

Here all the parameter will join with index.php?.......

So if you required to pass some parameter by default then you can write index.php?para=1......

But don not leave it blank form action value, by default it will consider the same url that is in address bar.

May this will help you .........:)

Upvotes: -1

boksiora
boksiora

Reputation: 1198

Put the incoming $_GET params in hidden fields

Upvotes: 0

Related Questions