<script language="javascript">
function get_ver() {
var ver = $("#OSVER option:selected" ).text();
alert ('valllllllllis' + ver);
}
</script>
print "<table width=100% cellSpacing=0 cellPadding=5 border=1 bordercolor='#006600' height=20 valign=top >";
print "<tr><td><h3>User Created BaaS Profiles</h3>";
print "</td></tr>";
while ($row=mysql_fetch_array($query))
{
$pol_type=$row['3'];
$pol_id=$row['0'];
$account_id=$row['2'];
$pol_ver=$row['pol_ver'];
$create_date=$row['create_date'];
$modifiy_date=$row['modifiy_date'];
if($uid == "1")
{
$sq="select * from baas_account where id=".$account_id;
}
else
{
$sq="select * from baas_account where id=" . $account_id . " and user_id=" .$uid;
}
$q=mysql_query($sq);
$row1=mysql_fetch_row($q);
$user_id=$row['user_id'];
$policy_name=$row1['2'];
$CSSUBS=$row['CSSUBS'];
$CSWKLYday=$row['CSWKLYday'];
$CSMNTday=$row['CSMNTday'];
//print "<form enctype='multipart/form-data' action='direct_submit.php' method='post' onSubmit='return validate();'>";
print "<tr id='info' name='info'>";
//print "<td><input type='radio' name='profile_select' value='$pol_id' /></td>";
{
print "<td><a href='index.php?xtype=user_admin'>$user_id</a></td>";
}
print "<td>";
//print "<p>$policy_name</p>";
print "<div class='texthv'>";
print "<a href='dnd.php?pid=$pol_id'>$policy_name</a>";
if($pol_type=='baseline') { print " "; }
else {
//print "<div class='texthv'>";
print "</br><b><a href='dnd.php?pid=$pol_id' class='texthidevisi'>View |</a></b>
<b><a href='index.php?xtype=create_policy&pol_id=$pol_id&pol_type=$pol_type&os_ver=b' class='texthidevisi' >Edit |</a></b>
<b><a href='index.php?pid=$pol_id&acc_id=$account_id&xtype=rename' class='texthidevisi'>Rename |</a></b>
<b><a href='index.php?pid=$pol_id&acc_id=$account_id&xtype=delete_file' class='texthidevisi'>Delete</a></b>
";
print "</div>";
}
print "</td>";
print "<td id='VER' name='VER'> <select id='OSVER' name='OSVER' onchange='get_ver();'>";
if($uid == "1")
{
$sql_pol_ver=mysql_query("select pol_ver from baas_profile where id=".$pol_id);
}
else
{
$sql_pol_ver=mysql_query("select pol_ver from baas_profile where user_id= " . $uid . " and id=" .$pol_id);
}
print "<option value=$pol_ver>$pol_ver</option>";
$pol_ver_arch=mysql_query("select pol_ver from baas_archive where user_id= " . $uid . " and id=" . $pol_id . " ORDER BY pol_ver DESC");
pol_ver_arch))
{
$pol_ver_old=$row['pol_ver'];
print "<option value=$pol_ver>$pol_ver_old</option>";
}
print "</select></td>";
if($pol_type=='baseline')
{
print "<td>CSC Baseline</td>";
} else{
$final_create_date = date("n/j/y H:i:s", $create_date);
$final_modifiy_date = date("n/j/y H:i:s", $modifiy_date);
print "<td> $final_create_date | $final_modifiy_date</td>";
}
print "</table>";
print "</td>";
print "</tr>";
我想获取下拉框的选择值,其id =&#39; OSVER&#39;在桌子里面。截至目前,我只能获得第一行的选定值,但不能获得后续行。有人可以帮忙吗?
答案 0 :(得分:0)
用
替换你的脚本<script>
function get_ver(el) {
var ver = $(el).closest("tr").find("option:selected").val();
alert(ver)
return false;
}
</script>
还有你的
onchange='get_ver();'
到
onchange='get_ver(this);'
当一个函数执行时,它获取this属性 - 一个带有对象值的变量,该对象调用使用它的函数。在你的情况下你还没有通过这个变量。希望你帮助你交配。 。:)
<强> FYI 强>
ID是一次性使用,仅适用于一个元素。它们用于标识单个元素。在您的情况下,您有一个名为OSVER
的ID,它不是唯一的。
小提琴here