1 回答
TA贡献1836条经验 获得超3个赞
<?php
echo "<select name='choose' id='choose' class='choose' onclick='selectfun()'>
<option value='radio' onclick='radio()'>RADIO</option>
<option value='checkbox'>CHECK BOX</option>
<option value='email'>EMAIL</option>
<option value='file'>FILE</option>
<option value='tel'>TELEPHONE</option></select>";
?>
<script>
function selectfun() {
// initializing the select tag to the variable selectBox
var selectBox = document.getElementById("choose");
// onclick reading the option value by select tag index
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
// checking the selected value is `radio` or not
if(selectedValue == 'radio'){
// if selected value is radio then alert the selected value
alert(selectedValue);
}
}
</script>
您可以使用echo
PHP 打印 HTML 代码,请查看我上面的代码,它可能会给您一些如何做到这一点的想法。
添加回答
举报