Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > odd variables in javascript

odd variables in javascript
Thread Tools
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Dec 14, 2003, 07:36 PM
 
I am making some javascript that updates some text input fields. But I have them names such that it is easy to put them into arrays in PHP for updating the database, but javascript is having a heck of a time with it.

Example, one input field name is "update_totals[2][title]"

but if I try to update or view that fields value in javascript, it does not want to work. for example the following in JS doesn't work:
document.myform.update_totals[2][title].value

any ideas how I can keep my field names as they are, and be able to use them in JS too?
     
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Dec 14, 2003, 08:03 PM
 
ok I got it. Here is what I came up with that works with input field names as array name for anyone else who might come across this and need help:

Code:
<script language="javascript" type="text/javascript"> <!-- function setShipping(method) { var thisForm = document.edit_order; thisForm["update_totals[2][title]"].value = thisForm["update_shipping["+method+"][title]"].value; thisForm["update_totals[2][value]"].value = thisForm["update_shipping["+method+"][value]"].value; } //--> </script>
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:33 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2