Solved

js not running...

Posted on 2012-04-11
3
237 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
  • 2
3 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 334 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 166 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 334 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now