W
William Holroyd
I haven't been able to find any resources on the internet about this and my
javascript books don't mention how to do this. So hopefully one of you guys
might be able to help me with this.
I'm building a website that needs to be able to check the value of an
element and give it a new value based on what it's current value is.
So for example, if I had a product and my code read like this...
<input type="text" name="name" size="20"><br>
<input type="text" name="description" size="20"><br>
<select size="1" name="public">
<option value="1">on</option>
<option value="0">off</option>
</select>
Assuming the name of my form was "form", I could access the value of the
text fields by "window.document.form.FIELDNAME.value" and the select by
"window.document.form.public.selectedIndex". But the page i'm working with
has multiple products listed and so I've addopted a nming convention for the
elements name's so that I could access it more efficiently in PHP. So for
example, I'd have multiple products as such...
<input type="text" name="product[1][name]" size="20"><br>
<input type="text" name="product[1][description]" size="20"><br>
<select size="1" name="product[1][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
<input type="text" name="product[2][name]" size="20"><br>
<input type="text" name="product[2][description]" size="20"><br>
<select size="1" name="product[2][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
<input type="text" name="product[3][name]" size="20"><br>
<input type="text" name="product[3][description]" size="20"><br>
<select size="1" name="product[3][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
But the problem is trying to interface these elements. How would I be able
to read the value of one of these elements?
Any help would be much appreciated.
-William
javascript books don't mention how to do this. So hopefully one of you guys
might be able to help me with this.
I'm building a website that needs to be able to check the value of an
element and give it a new value based on what it's current value is.
So for example, if I had a product and my code read like this...
<input type="text" name="name" size="20"><br>
<input type="text" name="description" size="20"><br>
<select size="1" name="public">
<option value="1">on</option>
<option value="0">off</option>
</select>
Assuming the name of my form was "form", I could access the value of the
text fields by "window.document.form.FIELDNAME.value" and the select by
"window.document.form.public.selectedIndex". But the page i'm working with
has multiple products listed and so I've addopted a nming convention for the
elements name's so that I could access it more efficiently in PHP. So for
example, I'd have multiple products as such...
<input type="text" name="product[1][name]" size="20"><br>
<input type="text" name="product[1][description]" size="20"><br>
<select size="1" name="product[1][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
<input type="text" name="product[2][name]" size="20"><br>
<input type="text" name="product[2][description]" size="20"><br>
<select size="1" name="product[2][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
<input type="text" name="product[3][name]" size="20"><br>
<input type="text" name="product[3][description]" size="20"><br>
<select size="1" name="product[3][public]">
<option value="1">on</option>
<option value="0">off</option>
</select>
But the problem is trying to interface these elements. How would I be able
to read the value of one of these elements?
Any help would be much appreciated.
-William