> -----Original Message----- > From: Skip Evans [mailto:skip@xxxxxxxxxxxxxxxxx] > Sent: 07 December 2009 23:03 > To: php-general@xxxxxxxxxxxxx > Subject: Passing HTML array index to JS? > > Hey all, > > I have an HTML field like this > > <input type="text" name="qty[]" value="!!quantity!!" size="4" > style="text-align: right;" onblur="calculateBidUnit();"> > > ... and what I need to do is pass to the calculateBidUnit > function the value of quantity, do a calculation on it and > plug into this field. > > <input type="text" name="bid_unit_value[]" value="" size="4"> > > Which of course I know how to do for non-array values, but not > sure how to get the values to do the calculation on the JS > side if the fields are in an array. H'mm, in my experience the only surefire foolproof way to make sure you pick the correct "bid_unit_value[]" input to match the corresponding "qty[]" is to actually supply specific array indexes (so "qty[1]", "bid_unit_value[1]"; "qty[2]", "bid_unit_value[2]"; etc.). There are other Javascript approaches that work in theory, but I've never been convinced of their robustness. As to addressing these elements, I merely observe that in Javascript, by definition a.z is *identical* to a["z"]. Application of this to the current situation is left as an exercise for the reader. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php