Jump to content
xisto Community
Sign in to follow this  
minnieadkins

Passing Select List As An Assoc. Array

Recommended Posts

I'm trying to pass a select list as an associative array, but evertime I do this the $key becomes numbered from 0 up like a normal array.

 

I have an onchange on a select list that generates an addbox. The currentbox is loaded the first time the page is loaded by pulling from the database. I want to only pull that one time, and each time the select list generates new results for the add box, I want the data inside of the current box to be sent to itself. Here's a diagram of the layout:

 

Posted Image

As you can see the arrows indicate that the items are to be moved from one list to the next, so it's basically a way to add new things to an object, or delete things from an object, but you can add several things to the object in different categories. When I want to change the categories of things to add I want the current list to remain intact.

 

Can someone please tell me a better way to do this, or how to send an associative array. As I said, I can send the array successfully, but when I get it from my $_POST variables, it sets the index to numeric. I'm also using the HTML notation for array. e.g. 'currentbox[]'

 

Help please :)

Share this post


Link to post
Share on other sites

There are different ways you can do things like that, the browser sends a http post request and it does not make the array and stuff, it just sends a lot of data and php makes all the arrays and stuff.So basically, you can use in the name="" values like array[current], array[][current] and anything you want, the [] will generate the a numeric index, so just use the function print_r($_POST) but before better add an [pre] html tag and look at what you need, and what array you want. :) it is easy.Good Luck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.