I am building an Ajax-application that functions as a 'formserver'.
A php-script is generating HTML-code for a form that is packed in XML that is sent to the browser via an XHTML-request.
There a Javascript-script makes the HTML-code part of the document tree.
I have problems with inputs of the 'radio'-type.
I first give the code that is needed to understand the problem.
a small piece of XML generated by the php-script:
<?xml version="1.0" encoding="ISO-8859-1"?>
<snapform>
<formdescription>
...
<formhtml><![CDATA[
...
<input type="radio" class="radio" name="_na_test" value="yes" />yes
<input type="radio" class="radio" name="_na_test" value="no" />no
...
]]></formhtml>
...
</formdescription>
</snapform>
this is part of a string that is sent from the server to the client in XML-format.
The client reads the whole string with the HTML-code into a variable and then makes it part of the documement tree using javascript like:
fielddiv.innerHTML=formHTML;
The form appears 'as expected' on the screen.
It doesn't go 'as expected' if I true to read the values of the radio-inputs.
(I use the Prototype-framework in this script)
radios=$(formName).getInputs('radio'); //reads all inputs of type 'radio' in the array radios
rname='t3_nothing';
for (i=0; i<radios.length; i++) {
if (radios[i].name!=rname) { //needed to avoid handling the same radiogroup multiple times
rname=radios[i].name;
radio=$(formName).elements[rname];
for (j=0;j<radio.length;j++){
alert(radio[j].name + ' ' +radio[j].value + ' ' +radio[j].checked);
}
}
}
Basicly I ask to 'alert' three attributes of the radio-input. The name-attribute and the checked-attribute are given correctly. The value attribute is empty.
Two questions:
1) Can anyone explain why this is happening?
2) What can i do to access the 'value'-attribute?