[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

js not running...

Posted on 2012-04-11
3
Medium Priority
?
245 Views
Last Modified: 2012-06-27
Two list boxes show some static data. Js included is expected to revise their content stored in an array fro each and also respond upon a click on these list boxes. It doesn't work.

Question: Could you possibly see what is wrong with it?

Thank you.
userinput.htm
designpalette.css
jquery-1.2.6.min.js
jquery-1.7.2.min.js
0
Comment
Question by:Mike Eghtebas
[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
3 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 1336 total points
ID: 37835131
There's a couple of things wrong with this:
<script type="text/javascript" src="jquery-1.2.6.min.js">

				

		alert("here");

		

		$('document').ready(function(){

		var groupNames = ["Group 1x", "Group 2x", "Group 3x", "Group 4x"];

		$.each(groupNames,function(){

		$('#group').append('</option>').text(this);

		});



		$.each(subgroupNames ,function(){

		var subgroupNames = ["Sub G  1x", "Sub G 2x", "Sub G 3x", "Sub G 4x"];

		$('#subgroup').append('</option>').text(this);

		});



		$('#group').click(function(){alert('group is clicked');});

		$('#subgroup').click(function(){alert('subgroup is clicked');});

		});

	</script>

Open in new window


This should get you closer:
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>

	<script type="text/javascript">			

		alert("here");

		

		$('document').ready(function(){

		var groupNames = ["Group 1x", "Group 2x", "Group 3x", "Group 4x"];

		$.each(groupNames,function(){

		$('#group').append('</option>').text(this);

		});


		var subgroupNames = ["Sub G  1x", "Sub G 2x", "Sub G 3x", "Sub G 4x"];

		$.each(subgroupNames ,function(){


		$('#subgroup').append('</option>').text(this);

		});



		$('#group').click(function(){alert('group is clicked');});

		$('#subgroup').click(function(){alert('subgroup is clicked');});

		});

	</script>

Open in new window

0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 664 total points
ID: 37835138
do this in your head section:-

<head>
	<title>Survey</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="styles/designpalette.css" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	
	<script type="text/javascript">
				
		alert("here");
		
		$('document').ready(function(){
		var groupNames = ["Group 1x", "Group 2x", "Group 3x", "Group 4x"];
		$.each(groupNames,function(){
		$('#group').append('</option>').text(this);
		});

		$.each(subgroupNames ,function(){
		var subgroupNames = ["Sub G  1x", "Sub G 2x", "Sub G 3x", "Sub G 4x"];
		$('#subgroup').append('</option>').text(this);
		});

		$('#group').click(function(){alert('group is clicked');});
		$('#subgroup').click(function(){alert('subgroup is clicked');});
		});
	</script>
</head>

Open in new window

0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 1336 total points
ID: 37835165
This is the corrected code to get the new list items appended:
alert("here");

		

		$('document').ready(function(){

		var groupNames = ["Group 1x", "Group 2x", "Group 3x", "Group 4x"];

		$.each(groupNames,function(i){

		$('#group').append('<option>' + groupNames[i] + '</option>');

		});


		var subgroupNames = ["Sub G  1x", "Sub G 2x", "Sub G 3x", "Sub G 4x"];

		$.each(subgroupNames ,function(i){


		$('#subgroup').append('<option>' + subgroupNames[i] + '</option>');

		});



		$('#group').click(function(){alert('group is clicked');});

		$('#subgroup').click(function(){alert('subgroup is clicked');});

		});

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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)
Suggested Courses

649 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