Solved

js not running...

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filktering Alphabetically 8 31
Using HTML5 and CSS How to place one element in front of another elemen 7 34
Media Queries  not Firing 6 19
Selected in an option list 13 21
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

828 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