Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Comments for: tim19991124

Message # 1023840:
Date: 01/17/05 17:51
By: Brock Weaver
Subject: RE: use of php array textbox in javascript

One option is to use the "id" attribute to grab the element via javascript instead of the name element.

Suppose you have this HTML:

<select name="phpfriendlyname[]" id="jsfriendlyname">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>

You would typically grab it via the form:
document.forms[0].phpfriendlyname[];

But of course javascript doesn't like the [] in the name. So grab it using the document object's getElementById method instead (which is IE/FF/Opera/Safari friendly):

var dropdown = document.getElementById('jsfriendlyname');

The "id" attribute is a DOM-only thing -- the HTTP request sent to the PHP site on a POST/GET is based on the "name" attribute, so PHP never sees the different "id" moniker.

Previous Message | Next Message


Comments:
RE: How do I create a feedback form?michael Mebrahtu07/21/08 06:47
arrays php and mysql Peter10/30/05 04:26
RE: PHP-mysql in drop-down menuvanes10/13/05 00:24
Arrays/CheckboxesGeoff06/20/05 22:56
T.Shail SOLUTION php array textbox javascriptvalian05/19/05 07:13
plz help me in php-mysqlRahul03/23/05 01:55
RE: use of php array textbox in javascriptBrock Weaver01/17/05 17:51
programming task use php apacheblack12/29/04 14:06
RE: use of php array textbox in javascriptT.Shailaja12/11/04 08:39
RE: How do I create a feedback form?Mwangi12/09/04 02:09
I need to verify checkboxes from a Formisa11/26/04 11:50
Working Code with MySQL + 3 files BESTiliana09/19/04 06:39
RE: ARG!! Help! PHP is not passing form dataglobal08/16/04 12:41
PHP5 Answer to .NetRagap Chettri07/28/04 00:45
RE: ARG!! Help! PHP is not passing form dataM-IT04/23/04 02:02
RE: php4 with Access 2000Ragap Chettri03/11/04 05:33
RE: accessing variables in an array w/ global offlpane11/21/03 22:18
RE: Post HashMike Marlett04/26/03 15:38
RE: ARG!! Help! PHP is not passing form dataToshesh04/22/03 04:15
Post HashStefan03/30/03 10:38
RE: i need help about form submit?mazsolt02/05/03 12:27
RE: Passing PHP URL variables no longer workal matthews12/21/02 06:43
RE: How do I make a newssystem???f00h12/07/02 06:50
RE: Passing PHP URL variables no longer workf00h12/07/02 06:34
i need help about form submit?devin10/24/02 00:34
Passing PHP URL variables no longer workASP rox10/19/02 16:41
What happenned with this form?ferdhie10/16/02 00:02
RE: ARG!! Help! PHP is not passing form dataPeter Watson10/15/02 11:41
For LoopBat Boy09/18/02 00:10
accessing variables in an array w/ global offlenn09/17/02 21:47
PHP code in Jscript functionMario Zammit09/16/02 21:53
RE: ARG!! Help! PHP is not passing form dataDebby09/12/02 22:36
Help with PHP, Form select option textBen09/11/02 05:58
Arrays from html to mysql via phprandom09/10/02 11:07
RE: ARG!! Help! PHP is not passing form dataCam09/03/02 00:33
How to execute PHP3 fileNeeraja08/29/02 12:18
ARG!! Help! PHP is not passing form dataRayvin08/28/02 17:07
RE: Can .html files use php tags?Thomas Anderson08/27/02 02:45
How do I make a newssystem???dennizzz08/25/02 14:27
RE: PHP arrays[] and JavaScriptRon08/16/02 14:16
PHP output in drop-down menuSanjay08/03/02 01:48
PHP output in FormSanjay08/02/02 09:26
RE: Help! php not communicating with htmlPHPslave07/30/02 20:36
Arrays,Javascript and PHPsezgin07/11/02 06:57
RE: passing javascript arrays to phphowardc07/01/02 14:32
RE: php4 with Access 2000charlie page06/24/02 16:27
RE: php4 with Access 2000no_names06/21/02 09:56
How about an Update page...Rick Heffernan06/20/02 16:21
Can .html files use php tags?John06/09/02 21:55
PHP arrays[] and JavaScriptJonathan Dickmann05/29/02 10:51
RE: This multiple select box ain't dynamicJoongonn05/28/02 00:27
Help! php not communicating with htmlrobin05/24/02 21:14
RE: checkboxes in forms with phpBrian05/23/02 09:57
RE: This multiple select box ain't dynamicMark Arenz05/22/02 15:46
RE: checkboxes in forms with phpparkley05/21/02 21:26
RE: checkboxes in forms with phpparkley05/20/02 22:27
RE: arrays and mysqlKim Gan05/10/02 21:46
RE: arrays and mysqlKim Gan05/10/02 21:45
RE: Possible to declare an array globally?Albert05/08/02 04:17
Pass PHP array to javascriptMark05/01/02 23:06
about session handling with checkboxes in phpamit05/01/02 03:58
RE: Using checkboxes in form with PHPEric Kaiser04/30/02 16:37
Arrayssuchi04/17/02 14:39
RE: Arrays, HTML, and PHPRemco de Jong04/11/02 11:21
RE: Arrays, HTML, and PHPRamsin04/05/02 11:28
RE: Arrays, HTML, and PHPLucas Jenkins03/26/02 11:49
RE: Arrays, HTML, and PHPTerry Simpson03/22/02 17:36
RE: multiple checkboxes in while loopcRAsH03/02/02 01:17
postgresql inserts, updates, delete with phpfunmi02/09/02 19:18
RE: This multiple select box ain't dynamicBob01/17/02 16:24
RE: checkboxes in forms with phpbiggus01/15/02 11:22
multiple checkboxes in while loopMayan01/13/02 15:14
checkboxes...luurich01/11/02 10:06
RE: checkboxes in forms with phpbugi01/10/02 16:01
Session handling with multiple formsMohit01/07/02 18:56
checkboxes in forms with phpChristine01/03/02 13:38
RE: php4 with Access 2000Naios KAE11/26/01 05:04
RE: arrays and mysqlhector garzon11/19/01 18:01
arrays and mysqlLen11/14/01 12:03
menu pop-up and PHPSidiney Sodré11/13/01 09:05
RE: New in PHP Programming LanguageKrishna11/07/01 03:45
This multiple select box ain't dynamicSeibs9811/01/01 10:19
New in PHP Programming LanguageJackie10/28/01 21:15
get data from dbaseantonio niz10/05/01 04:19
RE: I need to create a feedback formicyou10/04/01 09:38
Possible to declare an array globally?Toan Pham10/03/01 21:51
RE: Postgresql syntax for functionsAl McGrath10/01/01 15:27
Variables in HTML with PHP3Nacho09/24/01 05:48
Postgresql syntax for functionsGrant09/20/01 03:35
Using checkboxes in form with PHPTran Van Truong09/17/01 02:01
which database can be edited in notepadParminder singh09/12/01 01:20
RE: passing javascript arrays to phpSnigdha09/01/01 01:44
RE: easier array handling in PHP4musadek, ahmad08/29/01 19:28
I need to create a feedback formdesigner07/10/01 10:19
Update a MySQL db with array contentsJon06/23/01 02:06
RE: Arrays, HTML, and PHPBill06/05/01 12:22
Dynamic Population Of List BoxShankar05/24/01 10:34
RE: Great stuff but....Shankar05/23/01 16:16
RE: two dimension arraysMarijn05/22/01 03:33
RE: Arrays, HTML, and PHPPeter 05/15/01 16:07
RE: two dimension arraysjohn05/11/01 09:25
Object's ArrayAna Jose05/09/01 06:46
Arrays;;;;Chris04/29/01 07:14
remove duplicates in an array.........Chiranjeevi Bhavansikar04/29/01 07:02
two dimensional arrays in javaMelissa04/28/01 19:49
RE: two dimension arraysphilip olson04/18/01 20:29
RE: php and form namesphilip olson04/18/01 20:21
RE: php and form namesDave04/18/01 08:38
pass an array to a pageAnurag04/12/01 07:20
easier array handling in PHP4Rüdiger Reinhardt04/12/01 06:02
php array and javascriptkeyur04/06/01 06:58
two dimension arraysDavid Vilellas04/05/01 17:37
Arrays, HTML, and PHPciprian04/04/01 04:36
passing javascript arrays to phpbrian03/19/01 02:24
cheersdan03/13/01 12:13
multidimensional arraysvanessa03/07/01 17:14
RE: arraysphilip olson02/25/01 11:32
ThanksCarl Morley02/20/01 18:19
LDAP Multidemnsional ArrayJohn D.01/17/01 13:52
flat text: search for & display 1 fieldDanny Bishop01/16/01 15:00
php and form namesNisha12/31/00 09:00
RE: php4 with Access 2000Anant12/29/00 06:25
arraysreese12/11/00 06:34
RE: php4 with Access 2000Beau11/29/00 01:14
php4 with Access 2000david11/21/00 10:44
Great stuff but....Dan Champion09/11/00 09:52
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.