Solved

code debug, js

Posted on 2012-04-10
7
250 Views
Last Modified: 2012-04-11
On a webpage, I have two list boxes with the data on display:

________________
| Group 1       |
| Group 2       |
| Group 3       |  <--  id= "group"
| Group 4       |
----------------------
________________
| Sub G 1       |
| Sub G 2       |  <--  id= "subgroup"
| Sub G 3       |
| Sub G 4       |
----------------------

I have groupData.js to add the followings:

1. Using the following arrays upload (replace) the data in both group and subgroup list boxes:

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

2. Upon a click on the list boxes to execute:

alert("You have clicked on group control"); or
alert("You have clicked on sub group control");

as applicable.

It doesn't quite perform. Could you please take a look at it. I am new to js and trying to understand it.

Thank you.
designpalette.css
userinput.html
groupData.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
  • 3
  • 3
7 Comments
 
LVL 20

Accepted Solution

by:
Proculopsis earned 400 total points
ID: 37831547
Not sure if this is what you want but take a look at this jsfiddle.
0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 100 total points
ID: 37832036
here you go:-

$('document').ready(function(){
$.each(groupNames,function(){
$('#group').append('</option>').text(this);
});

$.each(subgroupNames ,function(){
$('#subgroup').append('</option>').text(this);
});

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

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37832923
HI  BuggyCoder,

What name should I be saving this file as?

Where and how do I include this in the html file?

Thanks,

Mike
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37832940
add it to head section of you aspx/html file as:-
<head>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$('document').ready(function(){
$.each(groupNames,function(){
$('#group').append('</option>').text(this);
});

$.each(subgroupNames ,function(){
$('#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


The first script reference is for JQuery File....
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37832968
The first script reference is for JQuery File....

Do I need to build this file? If so what is its content?

Where do I introduce:

var groupNames = ["Group 1x", "Group 2x", "Group 3x", "Group 4x"];
var subgroupNames = ["Sub G  1x", "Sub G 2x", "Sub G 3x", "Sub G 4x"];
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37833024
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37833028
Proculopsis,

I never have used this (your link type). It is very nice.

Mike
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html split(text) Part2 6 25
Text color in a select 11 23
CSS - how to make button/link change to black on hover? 2 19
output in HTML format powershell 6 25
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

730 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