Jquery dynamically populating a select option tab?

I'm not sure what dynamicVariable looks like, but here's how you can populate time with a Javascript array: var times = "Morning", "Afternoon", "Evening"; for(i in times) { $("#time"). Append( $(""). Attr("value", timesi).

Text(timesi) ); } Edit to answer your comment: Concatenate your list: List items = (List)Model. OpenCloseTimedynamicVariable. AppointmentTimes; string itemsStr = string.

Join(",", items.toArray()) Print it in your javascript: var items = "Attr("value", items_arri). Text(items_arri) ); }.

I'm not sure what dynamicVariable looks like, but here's how you can populate #time with a Javascript array: var times = "Morning", "Afternoon", "Evening"; for(i in times) { $("#time"). Append( $(""). Attr("value", timesi).

Text(timesi) ); } Edit to answer your comment: Concatenate your list: List items = (List)Model. OpenCloseTimedynamicVariable. AppointmentTimes; string itemsStr = string.

Join(",", items.toArray()); Print it in your javascript: var items = ""; Explode the string into a Javascript array: var items_arr = items. Split(","); Use what I posted above to make the select box: for(i in items_arr) { $("#time"). Append( $("").

Attr("value", items_arri). Text(items_arri) ); }.

And of course you can replace the for with a jQuery $. Each – Alec Ananian Sep 30 at 17:07 My issue is that the dynamicVariable is supposed to be the int value that will act as index value for my Model Object to retrieve the specific List, which is then will be used to populate the select tag. – OBL Sep 30 at 17:13 You're going to have to concatenate your List into a comma-delimited string then use more Javascript logic to parse it.

Javascript can't read your ASPX code straight like that. – Alec Ananian Sep 30 at 17:17 How do I do that? – OBL Sep 30 at 17:27 I updated my answer with how you can go about doing my solution.

– Alec Ananian Sep 30 at 19:33.

Here is and example of populating a select list using jQuery: function setCategory(categoryList) { var options = 'Select by Category'; for (var I = 0; I ' + categoryListi + ''; }; $("#categorySelect"). Html(options); }; Note, THIS also sets a default text using the first line, which may not be a desire here.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions