как правильно передвать имя radiobutton в функции
у меня в форме набор из radiobutton, checkbox и текстовых полей.
мне надо чтобы перед отправкой формы шла проверка - все ли radiobutton пользователь отметил. если не все - выдавать ему предупреждение и форму не отправлять. проблема в том, что кнопка в которой имя элемента задается напрямую ( <BUTTON TYPE = BUTTON ONCLICK="alert(getCheckedValue(document.forms['aef'].elements['articletype']));">Check2</BUTTON>) - работает а фунция CallOnSubmit, в которой я пытаюсь передавать имя набора radiobutton с вызовом той же функции getCheckedValue(document.forms['aef'].obligatory_radiobutton_array[j])- не работает! исходя их этого создается впечатление что имя набора radiobutton я передаю неправильно. подскажите, пожалуйста, как его правильно передвать. функция проверки radiobutton такая
// сперва функция проверки radiobutton
function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
функция проверки всей формы такая
function CallOnSubmit(){
// массив с именами обязательных к заполнению radiobutton
var obligatory_radiobutton_array = ["articletype", "studycoverage", "studysampling", "studiedpopulationage", "studiedpopulationsex", "studiedpopulationurbanicity", "studydesign", "studyfollowup", "otherriskfactors"];
var obligatory_radiobutton_names_array = ["Article type", "Study population coverage", "Study sampling strategy", "Studied population age", "Studied population sex", "Studied population urbanicity", "Study design", "Does study include follow-up", "Do risk factors for CKD in studied population are reported"];
var string4notice = "";
for(j = 0; j < obligatory_radiobutton_array.length; j++) {
if (getCheckedValue(document.forms['aef'].obligatory_radiobutton_array[j]) == "")){
string4notice = string4notice + "\n\r" + obligatory_radiobutton_names_array[j];
}
}
if(string4notice != ""){
string4notice = "Please note the following questions have to be answered before Abstract estimation form submission:" + "\n\r" + string4notice;
alert (string4notice);
}
return false;
}
а форма такая <form action="examination_step2.php" method="post" name="aef" id="aef" target=_parent> <BUTTON TYPE = BUTTON ONCLICK="CallOnSubmit();">Check</BUTTON><br> <BUTTON TYPE = BUTTON ONCLICK="alert(getCheckedValue(document.forms['aef'].elements['articletype']));">Check2</BUTTON><br> ... <div class="abstract_estimation_list"><label><input type="radio" name="articletype" value="1" />original article</label><br /> <label><input type="radio" name="articletype" value="2" />review article with data from developed world</label><br /> <label><input type="radio" name="articletype" value="3" />review article with data from developing world</label><br /> <label><input type="radio" name="articletype" value="4" />review article without mentioning the region of description</label><br /> <label><input type="radio" name="articletype" value="5" />review article without abstract (title suggests usefulness)</label><br /> <label><input type="radio" name="articletype" value="6" />registry report</label><br /> <label><input type="radio" name="articletype" value="7" />official report for health authorities</label><br /> <label><input type="radio" name="articletype" value="0" />other</label><br /></div> ... |
сделал по другому, ответ здесь http://javascript.ru/forum/showthrea...5163#post65163
|
Вот тут в пятом видеоуроке есть про то как правильно передвать имя radiobutton. Счас выложу заодно и все уроки .
Ссылка на скачивание Имя файла http://depositfiles.com/files/pl8npxytb 1.wmv http://depositfiles.com/files/yua7rtb07 2.wmv http://depositfiles.com/files/q04g8kc6s 3.wmv http://depositfiles.com/files/pfkqb9nl0 5.wmv http://depositfiles.com/files/e4213n66n 4.wmv http://depositfiles.com/files/ul99bco18 7.wmv http://depositfiles.com/files/c2hc4bpl7 JavaScript.rar тут все уроки вместе... ))) |
| Часовой пояс GMT +3, время: 22:02. |