Solved

js not running...

Posted on 2012-04-11
3
238 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
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…

910 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

22 Experts available now in Live!

Get 1:1 Help Now