Solved

code debug, js

Posted on 2012-04-10
7
237 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 33

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 33

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 33

Author Comment

by:Mike Eghtebas
ID: 37833028
Proculopsis,

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

Mike
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

Title # Comments Views Activity
Bootstrap 3 and Angular 2 12 23
angularls and plnkr 14 17
Login area of a page 4 19
After moving to webstite page stopped working 7 9
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
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.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 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