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 |