RE: [PHP] associative arrays in html forms and javascript
This is because you currently only have one field on your form named arraystuff. The browser only creates an array of elements if there is more than one of them. arraystuff.focus(), would work at present. -Stewart -Original Message- From: Daniel James [mailto:[EMAIL PROTECTED]] Sent: 08 August 2001 12:56 To: [EMAIL PROTECTED] Subject: [PHP] associative arrays in html forms and javascript Hi everyone :) imagine this if you will.. html body onload=document.formname.inputfield.focus() form name=formname input type=text name=inputfield /form /body /html ugly form with a text input field that is focussed when the form loads, erm.. nice. now, I like to put all my form stuff into associative arrays, makes things a lot nicer when I am doing things later... but this... means something completely different to javascript: html body onload=document.formname.arraystuff[inputfield].focus() form name=formname input type=text name=arraystuff[inputfield] /form /body /html and like that the text field won't focus and the parser tells me that arraystuff has no properties and that inputfield is undefined. I've tried all sorts of stuff, at the moment when I do a form I choose between javascript and associative arrays, depending on what I need... but I *want* both ;-) anyone have any ideas? I keep getting errors myself. Twigman... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] associative arrays in html forms and javascript
Yes, I find I have to do this a lot if I have multiple rows in a form and I want to do anything with javascript. I use commands like this: document.formname[the_checkbox[9]].checked = true and if you needed to stick a variable in the index: theform[the_checkbox[+the_index+]].checked = true; So on yours I think it would be like this: document.formname[arraystuff[+inputfield+]].focus or body onload = 'document.formname[arraystuff[+inputfield+]].focus' Tim McGuire Minnesota The only time I ever run is when I light a roach bomb in my apartment --- Daniel James [EMAIL PROTECTED] wrote: Hi everyone :) imagine this if you will.. html body onload=document.formname.inputfield.focus() form name=formname input type=text name=inputfield /form /body /html ugly form with a text input field that is focussed when the form loads, erm.. nice. now, I like to put all my form stuff into associative arrays, makes things a lot nicer when I am doing things later... but this... means something completely different to javascript: html body onload=document.formname.arraystuff[inputfield].focus() form name=formname input type=text name=arraystuff[inputfield] /form /body /html and like that the text field won't focus and the parser tells me that arraystuff has no properties and that inputfield is undefined. I've tried all sorts of stuff, at the moment when I do a form I choose between javascript and associative arrays, depending on what I need... but I *want* both ;-) anyone have any ideas? I keep getting errors myself. Twigman... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] associative arrays in html forms and javascript
html body onload=document.formname.arraystuff[inputfield].focus() form name=formname input type=text name=arraystuff[inputfield] /form /body /html and like that the text field won't focus and the parser tells me that arraystuff has no properties and that inputfield is undefined. body onload=document.formname.elements['arraystuff[inputfield]'].focus() ... should work. - Colin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]