Thomas 'PointedEars' Lahn wrote:
tomb wrote:
I am retrieving data through AJAX, and all my data elements are being
populated beautifully, except my radio button. If the value retrieved
is the first one, it gets selected,
Probably it doesn't and it was checked by default.
but if it's the second or third,
You mean if there is more than one radio button? Because, if we assume that
`f' refers to a form control, that is when your code is supposed tofail as
radio buttons are grouped by `name' attribute, and their corresponding DOM
objects are items of a NodeList then.
they are ignored and none of them gets selected. Can someone enlighten
me as to how the correct one gets selected?
pairs[0] represents the element id.
pairs[0] doesn't even occur in the posted snippet.
I currently have this in my js code:
if(f.type == 'radio'){
if(f.value == pairs[1]){
f.checked = true;
}
}
You don't say what `f' is, your code style is beyond good and evil (*11*
*tabs* for indentation!), you haven't RTFM or STFW, and you haven'tchecked
the error console. Try again.
<
http://jibbering.com/faq/#posting>
PointedEars
Criticism of coding style and the number of tabs in a line, is far from
enlightening. I'm sorry to bother you, but I don't have a manual. And
the source online that I do have I have no idea how to even approachthe
issue to look it up. Maybe the difficulty for you was understanding
what my issue is in the first place. So I'll rephrase it for you. I
don't know how to cause the correct radio button to be selected after
retrieving a value from the database. There - no code to critique, just
a simple question.
In the HTML use something like:
<input id="polar1" name="pol" type="radio" value="v" checked="checked"
onclick="availCalc()" />Vertical
<input id="polar2" name="pol" type="radio" value="h" onclick="availCalc
()" />Horizontal
And in the JavaScript refer to the name like this:
if (document.coords.pol
.checked) {
polar = document.coords.pol.value;
}
Regards, Steve.