具有相同名称的多个下拉列表以进行验证。 [英] Multiple dropdownlists with same name to validate.
问题描述
请帮帮我们,
我页面上有一个按钮,每次我们点击都会将下拉列表项添加到页面上。
因此,如果我单击按钮3次,那么我将在页面上有3个下拉列表项。 />
现在问题是我要验证它们,
我正在使用它..
Hi,
Please need help guys,
I have a button on the page , each time we click that adds dropdownlist items on to the page.
So if i click the button 3 times so i will have 3 dropdownlist items on the page.
Now the problem is i wants to validate them,
I am using this..
var extrapetid = document.getElementsByTagName('select');
for (i = 0; i < extrapetid.length; i++) {
var value = $("extrapetid[i] option:selected").val();
if (extrapetid[i].val() == "") {
valid = false;
}
}
我想检查选择的值是否为 valid = false。
我用它来迭代页面上的每个选择项并获得它的选定值但是
但是没有好运,我总是得到错误或没有得到价值。
请帮帮我
I wants to check if the seleted value is "" make it valid=false.
I am using it to iterate each select item on the page and get the selected value of it but
But no luck in that i always getting error or not getting the value.
Please help me
推荐答案
( extrapetid [i]选项:选择)。val();
if (extrapetid [i] .val()== ){
valid = false ;
}
}
("extrapetid[i] option:selected").val(); if (extrapetid[i].val() == "") { valid = false; } }
我想检查选择的值是否为 valid = false。
我用它来迭代页面上的每个选择项并获得它的选定值但是
但是没有幸运的是,我总是得到错误或没有得到价值。
请帮助我
I wants to check if the seleted value is "" make it valid=false.
I am using it to iterate each select item on the page and get the selected value of it but
But no luck in that i always getting error or not getting the value.
Please help me
jQuery无法将此解析为知道需要对extrapetid [i]进行评估。相反,为每个控件的名称添加一个索引,如control1,control2,然后使用extrapetid [i]访问该对象,并获取它的唯一ID并将其传递给jquery照常。拥有大量具有相同ID的控件并不是一个好主意。你怎么分辨他们?
jQuery can't parse this to know that extrapetid[i] needs to be evaluated. Instead, add an index to the name for each control, like control1, control2, then use extrapetid[i] to access the object, and get it's unique id and pass that to jquery as normal. Having lots of controls with the same id is not a good idea. How do you tell them apart ?
这篇关于具有相同名称的多个下拉列表以进行验证。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!