M
Martin O'Rourke
All,
I am hoping someone might be able to put me out of my misery and let me
know if it is possible or not to dervie the name of an element in a
form, based on its associated label, only knowing the value of the
label, and working on the assumption that the <label for="???" links to
the <select id="???"
Below is the html that I am working from, which has been dynamically
created. Unfortunately I have no control over this at all. I need to
obtain the name of the drop down, so I can derive the country code
(.value) and the country name (.text) but the only constant I have is
knowing that it will be labelled up "Country".
Below is the HTML I am seeing along with the Pseduo code I think I will
need to implement. I have
removed my JavaScript effort to save embarressment on my part.
If anyone can help, provide code, or point me in the right direction
then I would really appreciate it.
Thanks All,
Martin
<html>
<head>
<script>
function abc(form_name)
{
// Pseudo Code
Search form to find the Label "Country"
Derived 'For' value. i.e. <label for = "N50"
Re-search form to find an id matching the previously found for value
i.e. search form where id for form element= "N50" <select id="N50"
Return name of form element i.e. HrAddressFlex0
}
</script>
</head>
<body>
<form id="DefaultFormName" name="DefaultFormName" method="POST"
action="www.dummyurl.com">
<table>
<tr>
<td align="right" nowrap>
<label for="N50">Country</label>
</td>
<td nowrap>
<select id="N50" name="HrAddressFlex0">
<option value="AFG">Afghanistan</option>
<option value="ALB">Albania</option>
<option value="ALG">Algeria</option>
</select>
</td>
</tr>
<tr>
<td align="right" nowrap></td><td>
<input type="button" name="submit_button" value="submit"
onclick="abc(this.form)">
</td>
<tr>
</table>
</form>
</body>
</html>
I am hoping someone might be able to put me out of my misery and let me
know if it is possible or not to dervie the name of an element in a
form, based on its associated label, only knowing the value of the
label, and working on the assumption that the <label for="???" links to
the <select id="???"
Below is the html that I am working from, which has been dynamically
created. Unfortunately I have no control over this at all. I need to
obtain the name of the drop down, so I can derive the country code
(.value) and the country name (.text) but the only constant I have is
knowing that it will be labelled up "Country".
Below is the HTML I am seeing along with the Pseduo code I think I will
need to implement. I have
removed my JavaScript effort to save embarressment on my part.
If anyone can help, provide code, or point me in the right direction
then I would really appreciate it.
Thanks All,
Martin
<html>
<head>
<script>
function abc(form_name)
{
// Pseudo Code
Search form to find the Label "Country"
Derived 'For' value. i.e. <label for = "N50"
Re-search form to find an id matching the previously found for value
i.e. search form where id for form element= "N50" <select id="N50"
Return name of form element i.e. HrAddressFlex0
}
</script>
</head>
<body>
<form id="DefaultFormName" name="DefaultFormName" method="POST"
action="www.dummyurl.com">
<table>
<tr>
<td align="right" nowrap>
<label for="N50">Country</label>
</td>
<td nowrap>
<select id="N50" name="HrAddressFlex0">
<option value="AFG">Afghanistan</option>
<option value="ALB">Albania</option>
<option value="ALG">Algeria</option>
</select>
</td>
</tr>
<tr>
<td align="right" nowrap></td><td>
<input type="button" name="submit_button" value="submit"
onclick="abc(this.form)">
</td>
<tr>
</table>
</form>
</body>
</html>