Sheerwood John Caday
Sheerwood John Caday

Reputation: 229

Add new get value on URL in Get form

I just want to ask if how to add new value on URL in form get method?

for example this is the current URL

http://dev.admin.com/?menu=atc_name_request&area=all&sort=reqcount

i want to add new value or get value like..

&from=2015-09-01&to=2015-09-01&sort=Sort

so the final URL would be

http://dev.admin.com/?menu=atc_name_request&area=all&sort=reqcount&from=2015-09-01&to=2015-09-01&sort=Sort

this is my code:

<form action="" method="get">
    From: <input type="text" id="datepicker" name="from" value=<? echo $_GET['from']; ?>>  To: <input type="text" id="datepicker2" name="to" value=<? echo $_GET['to']; ?>>
    <input type="submit" name="sort" id="button" value="Sort"> 
  </form>

what I get is

http://dev.admin.com/?menu=atc_name_request%26area%3Dall%26sort%3Dreqcount&from=2015-09-08&to=2015-09-02&sort=Sort

Upvotes: 1

Views: 1204

Answers (1)

MaggsWeb
MaggsWeb

Reputation: 3017

Why not just add each required parameter in the URL as a hidden form field.

<form action="" method="get">
  From: <input type='text' id='datepicker'  name='from' value='<?=$_GET["from"]?>' />  
  To:   <input type='text' id='datepicker2' name='to'   value='<?=$_GET["to"]?>' />

  // Add hidden fields..
  <input type='hidden' name='menu' value='<?=$_GET["menu"]?>' />
  <input type='hidden' name='area' value='<?=$_GET["area"]?>' />
  <input type='hidden' name='sort' value='<?=$_GET["sort"]?>' />

  <input type="submit" name="submit" id="button" value="Sort" /> 
</form>

Upvotes: 1

Related Questions