[UPHPU] Javascript and Square braces

Fred Larsen fred at bitwyze.com
Fri Feb 3 15:07:18 MST 2006

On Feb 3, 2006, at 2:59 PM, TJ Hunter wrote:

>> So .. I have a form called "Cart"
>> I also have form elements with "quantity[$item_id]" as their name:  
>> <input
>> type="text" name="quantity[2]">
>> I would like to modify this element via javascript.  I know I should
>> probably just rename it to quantity_2 and parse the vars .. but  
>> this square
>> braces method of variable passing keeps coming up a lot.
> give the element an id:
> <input id="quanity_2" type="text" name="quantity[2]">
> then with javascript you can modify it by doing something like:
> document.getElementById("quanitity_2").value = "2";

I  use  document.forms[0].elements['quantity[]'].value;

Solves the problem and is cross browser.


More information about the UPHPU mailing list