Watch Our YouTube Channel
It is currently Sat Dec 16, 2017 5:13 am
 

All times are UTC



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Oct 01, 2013 12:22 pm 
Offline

Joined: Tue Jan 29, 2013 10:24 am
Posts: 145
Location: India
If we are having two select boxes, We need to change the value of one select box according to the selection of another select box.

Find below code to do the above changes.

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
 /*function for changing age when changing the name
 */
 function setage()
 {
  var index_name=document.frmselect.name.selectedIndex;
  document.frmselect.age.selectedIndex=index_name;
 
 }
 /*function for changing name when changing the age.
 */
 function setname()
 {
  var index_age=document.frmselect.age.selectedIndex;
  document.frmselect.name.selectedIndex=index_age;
 
 }
</script>
</head>

<body>

<form name="frmselect" id="frmselect" action="" method="post">
<table>
<tr><td>
 <select name="name" id="name" onChange="setage()">
  <option value="" selected>Select Name</option>
  <option value="1">Name1</option>
  <option value="2">Name2</option>
 </select>
</td>
<td>
 <select name="age" id="age" onChange="javascript:return setname();">
  <option value="" selected>Select Age</option>
  <option value="a">Age1</option>
  <option value="b">Age2</option>
 </select>
</td></tr>
</table>
</form>
</body>
</html>


Output:
Attachment:
select.jpg
select.jpg [ 15.17 KiB | Viewed 898 times ]

_________________
K.Suresh Kumar
Motivational Quotes | Web Development | Software Testing


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron