Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Passing Select List As An Assoc. Array
minnieadkins
post Feb 2 2006, 09:23 PM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 292
Joined: 15-December 04
Member No.: 1,768



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
Go to the top of the page
 
+Quote Post
Quatrux
post Feb 3 2006, 07:31 AM
Post #2


the Q
Group Icon

Group: [HOSTED]
Posts: 1,094
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059
myCENTs:70.96



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Sql Injection Prevention (passing Numerical Data Across Pages).(9)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 04:35 PM