homepage Welcome to WebmasterWorld Guest from 54.145.182.50
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Pass an array in a hidden field
damiantaylor



 
Msg#: 4111607 posted 6:06 pm on Apr 7, 2010 (gmt 0)

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.example.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.example.com&main_page=index&Flt_Grade%5B%5D=100&filter_id=4

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

But what I actually get is
www.example.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?

[edited by: tedster at 8:00 am (utc) on Apr 8, 2010]
[edit reason] switch to example.com - it cannot be owned [/edit]

 

coopster

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



 
Msg#: 4111607 posted 6:05 pm on Apr 8, 2010 (gmt 0)

Are you viewing that before it leaves your browser or after the PHP parser has handled the request? Because PHP builds the array for you, removing the brackets before populating the $_GET superglobal.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved