I have multiple select boxes, say: ID, RollNo, Name and class.
If ID is set ,I want to reset the RollNo, name and class to nothing or blank.
My web page
<?php echo $this->Form->input('id',
array("options"=>$databaseFields->getOptions("id",1))); ?>
<?php echo $this->Form->input('RollNo',
array("options"=>$databaseFields->getOptions("rollno",1))); ?>
<?php echo $this->Form->input('name',
array("options"=>$databaseFields->getOptions("name",1))); ?>
<?php echo $this->Form->input('class',
array("options"=>$databaseFields->getOptions("class",1))); ?>
You can achieve this easily using jQuery. Since we don't have much information about your HTML I present a more generalized solution.
Add the following to your <head>
:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
(or download the .js file and point to it's local path)
Then add something along these lines also on the <head>
of your document:
$(document).ready(function()
{
$("#selectID").change(function()
{
//Reset any select boxes
$("#selectOther")[0].selectedIndex = 0;
});
});
You can see a working example at http://jsfiddle.net/zPhnN/1/
This should be modified to suit your needs, but hopefully it's something to get you started.
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.