Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Pass array in hidden field

     

damiantaylor

6:57 pm on Apr 6, 2010 (gmt 0)

5+ Year Member



Hi all!
I'm trying to pass an array as a hidden field from a form in the URL of the browser but it's not working.
Can you tell me what is wrong with this...it's my first attempt so be gentle :)

The form HTML is

<form name="filter" action="http://www.myurl.com" method="get">

<input type="hidden" name="main_page" value="index" />
<input type="hidden" name="Flt_Grade[]" value="100" />

<select name="filter_id" onchange="this.form.submit()">
<option value="1">Most Popular</option>
<option value="2" selected="selected">Price: Low to High</option>
<option value="3">Price: High to Low</option>
<option value="4">Title</option>
<option value="6">Date Added: Newest</option>
<option value="7">Date Added: Oldest</option>
</select>

</form>


I would expect, when option 4 in the dropdown is selected the URL to be
www.myurl.com&main_page=index&Flt_Grade%5B%5D=100&filter_id=4

Where %5B = [ and %5D = ]

But what I actually get is
www.myurl.com&main_page=index&Flt_Grade=&filter_id=4

The Flt_Grade array is not passed properly.

Can this be done so the hidden field is passed in the URL as an array?

brotherhood of LAN

3:26 am on Apr 9, 2010 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Did you get this working?

I saved your HTML on a test.php page, on its own, and it worked fine.

Output using print_r($_GET):
Array (
[main_page] => index
[Flt_Grade] => Array ( [0] => 100 )
[filter_id] => 4
)

coopster

10:00 pm on Apr 9, 2010 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



cross post:
[webmasterworld.com...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month