Solved

code debug, js

Posted on 2012-04-10
7
247 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
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…
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…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

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