Passing Select List As An Assoc. Array

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Passing Select List As An Assoc. Array

minnieadkins
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:

user 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 smile.gif

 

 

 


Reply

Quatrux
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. wink.gif it is easy.

Good Luck.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.







*SIMILAR VIDEOS*
Searching Video's for passing, select, list, assoc, array
advertisement




Passing Select List As An Assoc. Array



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE