Jump to content

Recommended Posts

Posted

This isn't really a script question, but here goes.

 

You know the way you can send hidden variables in a form using the <input> tag. Well, I'm trying to send a hidden array variable. Arrays are normally sent through the <select multiple="multiple"> tag and I would like to send one while hidden.

 

Is there any way of doing something like this. I was thinking about a workaround. I could build the form like normal, and use css tags to make it invisible.

 

What do you think? If you need clarification, Just let me know. I can post an example if neccessary.

Posted

nope, just to clarify something...it won't be using php.

 

If there is such a thing, It will be something along these lines

<input type="hidden" name="myarr" value="serialized_array" />

Posted

You almost got it:

<input type="hidden" name="myarr[]" value="serialized_array" />

 

The answer is those [ ] in the name attribute.

 

Hope it helps :)

Posted

Geez, That was it....

cassetete.gif

 

Whats this, the 100th time Raul has helped me out. You deserve an award of some kind.

 

Here is the final code for anyone else that ever needs to do something simliar.

 

><form action="foobar.php"  method="post">
   <input type="hidden" name="myarr[]" value="5" />
   <input type="hidden" name="myarr[]" value="7" />
<input type="submit" />
</form>

 

This will send a post variable ( $_POST['myarr'] ) as an array, indexed like the following.

myarr[0] -> 5

myarr[1] -> 7

Posted (edited)

An award? No way! I just like to help out where I can :lol:

 

 

 

 

 

Psst, by the way, that's my bank account number, in that PM I just sent you... :) :) :oops:

Edited by TCH-Raul

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...