Solved

want one select menu choice to change another select menu choice

Posted on 2013-05-28
4
374 Views
Last Modified: 2013-05-29
<select name="choice1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<select>

if option 1 is selected then
<select name="choice2">
<option value="1">1</option>
</select>

if option 2 is selected then
<select name="choice2">
<option value="1">1</option>
<option value="2">2</option>
</select>

if option 3 is selected then
<select name="choice2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Ahmed Hussein earned 250 total points
ID: 39202900
Here it is.

<script>
$(document).ready(function(){

	function changeValue(value){
		$("select[name='choice2']").html("");
		for(var i = 1; i <= value; i++){
			$("select[name='choice2']").append('<option value="'+i+'">'+i+'</option>');
		}
	}
	
	changeValue($("select[name='choice1']").val());
	$("select[name='choice1']").change(function(){
		changeValue($(this).val())
	});
});
</script>
<select name="choice1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<select>

<select name="choice2">

</select>

Open in new window


~AG
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 39202901
0
 

Author Comment

by:rgb192
ID: 39206322
by: AhmedGeekPosted on 2013-05-28 at 17:38:31ID: 39202900
select name=choice1
does not populate choice2
0
 

Author Closing Comment

by:rgb192
ID: 39206331
both work with adding
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

slightly different code samples

thanks both
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question