In the AJAX submission processing vote, there is a question of extracting the ID value of a single box. After research, reference network, and finally achieved success. The following is an AJAX code fragment:
Get INPUT Element
var e=document.getelementsbytagname ("input");
Defines the initial value of a single marquee, which is valid when no option is selected, and uses it as a flag to select a single selection
var item_id= "";
for (Var i=0;i<e.length;i++) {
Radio is a radio box, name of a radio box, practical change according to the actual situation
if (e[i].type== "Radio" &&e[i].name== "item_id" &&e[i].checked)
When you select a radio box, get the value of this box
Item_id=e[i].value;
}
If you do not select a single selection, you are prompted for an error
if (item_id== "") {
Alert ("Please select the voting option!") ");
return false;
}else{
The following is the normal code of execution, slightly
}
The following is a better solution, tested successfully through:
var e=document.getelementsbyname ("item_id");
var item_id= "";
for (Var i=0;i<e.length;i++) {
if (e[i].checked)
Item_id=e[i].value;
}
if (item_id== "") {
Alert ("Please select the voting option!") ");
return false;
}else{
The following is the normal code of execution, slightly
}
Through the code can be seen, this code is targeted only to take name= "item_id" input elements, efficiency shows much more efficient, and no error.
A single check box effect is handled using the following code:
var f=document.getelementsbyname ("Isindex");
var isindex= "";
for (Var i=0;i<f.length;i++) {
if (f[i].checked)
Isindex=f[i].value;
}
Multiple check box effects, which is estimated to be an accumulation of values, the following code has not been tested:
Isindex=isindex+ "," +f[i].value;