Re: passing random variables names

From: Date: Fri, 07 Nov 2003 08:53:47 +0000
Subject: Re: passing random variables names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-168806@lists.php.net to get a copy of this message
On Fri, 2003-11-07 at 09:40, Yonatan Ben-Nes wrote: > Hi all, > > I made a form which pass constant variables which never change (Ex. product_name) and dynamic > variables which i withdraw from the db (Ex. attribute_id = 1, value = color). > Now my problem is with the passing of the dynamic variables. > Because the fields can change their name (id's) i need to design my functions so they will > "know" how to receive them. > I used to make an array in the form (Ex. attribute_id[0], attribute_id[1] where the numbers in > the [] are the id numbers from the db) and then at the function i used to > $_POST['attribute_id'] and then withdraw from them their id's and values. > I read that this kind of passing variables is making problems with javascripting (and maybe it > violate W3C standards). > Is there a way that i can pass names like attribute_id_X where X is the changing name and the > function will be able to withdraw it like $_POST['attribute_id_X'], or any other way which > doesnt violate W3C standards? > > Any help will be greatly appreciated, It should be possible to access these kind of fields in javascript. Eg. if you have an input field named attribute_id[1] you access that field by doing like this: documents.form_name.elements['attribute_id[1]'].value Try that > Thanks > ------------------------------------------------------ > "My friends are worth gold to me, so I prefer to sell them and get rich!" > > Ben-Nes Yonatan > Canaan Surfing Ltd > Tel: 972-4-6991122 > Fax: 972-4-6990098 > http://www.canaan.net.il > ------------------------------------------------------ -- Venlig hilsen / Best regards, Jacob Vennervald System Developer Proventum Solutions ApS Tuborg Boulevard 12 2900 Hellerup Denmark Phone: +45 36 94 41 66 Mobile: +45 61 68 58 51

« previous php.general (#168806) next »