SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Microsoft .NET :

Previous DiscussionNext Discussion
 JSON question -- can any SE regulars help??

Ok, here's the scenario. I have a web app that I'm using AJAX and a web service in.

The AJAX is used to create the ModalPopup.

So I have a JavaScript called ModalPopupFunctions.js that contains a function like this:

function PopulateDropDowns(json)
{
var p, t, s, si;
var ddl = document.getElementById('myDDL');
var opt = document.createElement('OPTION');

eval("p = " + json);

// Priorities Drop-Down List.
removeOptions(ddl,p.DataList.length); // Remove any options that may be present.

// Use the addOption function to populate the correct DropDownList.
for(var i = 0; i < p.DataList.length; i++)
{
addOption(ddl, p.DataList[i].Desc, p.DataList[i].ID);
}
}

function addOption(selectbox,text,value)
{
var opt = document.createElement("OPTION");

selectbox.options.add(new Option(text));
opt.text = text;
opt.value = value;
selectbox.options.add(opt);
}

// Removing options from the appropriate drop down list.
function removeOptions(selectbox, numberOfItems)
{
for(var i = numberOfItems - 1; i >= 0; i--)
{
selectbox.remove(i);
}
}


Now, I can use this to populate a DropDownList (select), but when I view source, it's empty, so I can't get the selected value to pass back to the server. In other words, the DropDownList gets populated, but in some weird way, where if I do a view source all I see is the select open and close markup, with no options in between.

What do I need to do to accomplish this?

Started By Monte on Feb 26, 2009 at 7:09:08 AM

17 Response(s) | Reply

Earlier Replies | Replies 3 to 3 of 17 | Later Replies
Goto Page: 3 2 1
MHenke on Feb 27, 2009 at 1:50:13 AM (# 3)

Just wondering how many SE non-regulars so far refused to answer your question, Monte. :D

However, here goes my SWAG:
What "View Source" you're talking about?
The "normal" view source, e.g. from the context menu tends to show you the HTML source code. That is, the initial one, that's been sent to the client. And if I'm right here, that's exactly what your <select> is in the source code: empty.

If you're using FF with the web developer extensions, there is a "View Generated Source" (no idea if IE has such a thing).
This will show you the code of the present, client side state of the page, incl. dynamic, client side changes (e.g. via JavaScript).

I'm not sure, but I'd guess that "View Source" literally do what it promises, whereas "View Generated Source" somehow reflects the current state of the DOM.

Well, enough blah, try it out... :)


Earlier Replies | Replies 3 to 3 of 17 | Later Replies
Goto Page: 3 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.