我正在研究php如何显示隐藏字段?
我的数据库中有bp_scholarship_enq表,这个数据库我有职业字段,我想在我的数据库中添加新的职业,我是怎么做的?
<script>
function showss(ids)
{
var idss=ids;
if(idss=="other")
document.getElementById(idss).style.display='block';
}
</script>
<?php
echo "<select name='occupation' id='link_block' value='Source' style='width:196%'>
<option>select occupation </otpion>";
$sql = "SELECT * FROM bp_scholarship_enq";
$info = mysql_query($sql);
while ($row = mysql_fetch_array($info))
echo "<option > '" . @$row["occupation"] . "'</option>";
echo '<option onClick="showss('.input_field.')">other</option>';
echo "</select>";
echo '<input type="hidden" name="other" id="input_field" />';
?>
发布于 2014-01-01 21:43:03
隐藏字段是不可见的。您可以使用文本框,并在css中将其可见性设置为false,并在更改select选项时使其可见。
<input type="text" name="other" id="input_field" style="display:none"/>
<select name='occupation' id='link_block' value='Source' style='width:196%' onChange="showText(this.selectedIndex);">
...............
...............
<option value="other">other</option>
</select>
<script>
function showtext(ind){
var selectBox = document.getElementById('link_block');
if(selectBox.options[ind].value=="other"){
document.getElementById('input_field').style.display = "block";
}else{
document.getElementById('input_field').style.display = "none";
}
}
</script>
发布于 2014-01-01 21:49:18
而不是
<input type="hidden" name="other" id="input_field" />
使:
<input id="otherOccupation" class="hide" name="other" id="input_field" />
隐藏是一个设置可见性的类:隐藏;
然后,当用户选择"other“时,使用jquery删除该类。
$("#otherOccupation").removeClass("hide")
https://stackoverflow.com/questions/20876991
复制