This is my code.
<?php
$qry5=mysql_query("SELECT * FROM `questions` WHERE `questnTime`=curdate()");
$quest=mysql_fetch_array($qry5);
?>
<form id="form" name="form" action="">
<textarea name="questn" id="questn" readonly="readonly" cols="45" rows="5">
<?php echo $quest['questnId']; ?>. 
<?php echo $quest['question'];?>
</textarea>
<input type="submit" class="myButton" name="option"
onclick="handleSubmit(this)" value="<?php echo $quest['optiona'];?>"/>
<input type="submit" class="myButton" name="option"
onclick="handleSubmit(this)" value="<?php echo $quest['optionb'];?>"/>
<input type="submit" class="myButton" name="option"
onclick="handleSubmit(this)" value="<?php echo $quest['optionc'];?>"/>
<input type="submit" class="myButton" name="option"
onclick="handleSubmit(this)" value="<?php echo $quest['optiond'];?>"/>
</form>
<?php
if($quest['answer']==$_GET['option']){
$option=$_GET['option'];
}
Javascript code:
<script type="text/javascript">
function handleSubmit(current){
var list = document.getElementsByName('option');
for(var i=0;i<list.length;i++){
if(list[i]!=current)
list[i].disabled=true;
}
alert('all disabled');
}
</script>
CSS:
<style>
input.myButton{
background-image: url('option.png');
background-color:#FFF;
height:32;
width:32;
border-style:hidden;
color: #FFFFFF;
}
</style>
What I require is when user clicks on an option all other options must be disabled. When an option is clicked, I want to get the value. Also I dont want the page to be refreshed. How to do this? The following code dosenot disable the options. Please help me!!!
在这种情况下,不要进行多次提交,将其作为按钮,然后单击,然后将所有禁用(单击一次除外)禁用,并将输入类型更改为提交。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.