473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Accessing form element with non-conventional naming

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
Jul 23 '05 #1
1 1062
William Holroyd wrote:
<snip>
<input type="text" name="product[3][name]" size="20"><br> <snip> Any help would be much appreciated.


<URL: jibbering.com/faq/#FAQ4_25 >

- and -

<URL: jibbering.com/faq/#FAQ4_39 >

Richard.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
4
by: Paweł | last post by:
We can access the Nth element in the first form by document.forms.elements imagine that theres function like <INPUT TYPE=TEXT" onclick="somefunction(this)"> and... we have function...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
6
by: David D. | last post by:
I want to be able to access cells within an HTML table, via computed row number and column number. I was considering using oTableID.children and oTR.children arrays. My question is what...
4
by: multimatum2 | last post by:
Hello, I need to enable/disable input text forms... But... I need to have the same style (color...) in both modes.. Could you help me ? Thanx a lot A small sample... ...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
2
by: lasher168 | last post by:
Hi, I have a problem which I have been on pondering all day and wasting time !!! I have a javascript call which looks like this <td width="50%" class="inputLabel"><span...
6
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
3
by: judy.j.miller | last post by:
Does anyone know why i can't access a form element value using dot notation in firefox, when i'm in a function. Works ok in the body. I'm trying to do this: var FarTemp = faren.temp.value; I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.