Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Populating multiple drop down menus fails w/o an Alert

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Programmers Exchange
View previous topic :: View next topic  
Author Message
boston1630
New one
New one


Joined: 09 Dec 2008
Posts: 1

PostPosted: Tue Dec 09, 2008 9:54 pm    Post subject: Populating multiple drop down menus fails w/o an Alert Reply with quote

Hi,

I'm trying to create an application that will use AJAX to populate multiple drop down menus on a web page. I'm working on a "Looking Glass" application for the ISP that I just joined, and I'm really hung up. The idea is to have the user select an option from column one, namely, which type of router family, and then to have the other two fields populate based on that choice.

The code that I appended at the end of this message will work the way that I intend using the alert button in the middle of the code. But, I would like to make this seamless for the end user, so the alert has to go. Unfortunately, when I remove the alert, the second field does not populate. It almost seems like there needs to be some other event in the code the make it operate properly.

All in all, I'm stuck, and any help that you can offer will be greatly appreciated.

Thanks!

-Mike

I built the following code using this guide as a reference:
http://www.webmonkey.com/tutorial/Build_an_Ajax_Dropdown_Menu

There are 5 files that are part of this application and the request.js file that was included in the reference.

File 1 -html page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transistional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns="http"//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
<title>Test Looking Glass</title>

<script src="request.js"></script>

<script>
function handleOnChange(dd1) {

var idx = dd1.selectedIndex;
var val = dd1[idx].text;
var par = document.forms["mainForm"];
var parelmts = par.elements;
var commandSelect = parelmts["selRtrCommand"];
var routerCommand = val;
var commandSelect2 = parelmts["selRouter"];

if (routerCommand != "Select Command") {
Http.get({
url: "./" + routerCommand + "-commands.txt",
callback: fillSelects,
cache: Http.Cache.Get }, [commandSelect]);
}
alert("It will only work with this in here!");
if (routerCommand != "Select Command") {
Http.get({
url: "./" + routerCommand + "-routers.txt",
callback: fillSelects,
cache: Http.Cache.Get }, [commandSelect2]);
}

}

function fillSelects(xmlreply, commandElmt) {

if (xmlreply.status == Http.Status.OK) {

var commandResponse = xmlreply.responseText;
var prezar = commandResponse.split("|");
commandElmt.length = 1;
commandElmt.length = prezar.length;

for (o=1; o < prezar.length; o++) {

commandElmt[o].text = prezar[o];

}
}

else {
alert("There is an error, please select an appropriate router.");
}
}

</script>

</head>

<body>

<form name="mainForm">
Router Type: <select name="selCommand" onChange="handleOnChange(this);">
<option>Select Command</option>
<option>Cisco</option>
<option>Juniper</option>
</select>
Router Command: <select name="selRtrCommand">
<option>Router Command</option>
</select>

Select Router: <select name="selRouter">
<option>Select Router</option>
</select>
<br>
<br>
<br>
<input type="submit" value="Submit" />
</form>

</body>
</html>

File 2 - Juniper-commands.txt
|sh bgp|sh bgp neigbor|sh ospf|sh ospf neighbor

File 3 - Juniper-routers.txt
|troy.isp.net|compton.isp.net|englewood.isp.net

File 4 - Cisco-commands.txt
|sh ip bgp|sh ip bpg neighbor|sh ip ospf|sh ip ospf neighbor

File 5 - Cisco-routers.txt
|birmingham.isp.net|lakeland.isp.net|orlando.isp.net
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Programmers Exchange All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert