DreamToCode
DreamToCode

Reputation: 291

loop through list of elements and read values via querystring

I am assigning values to an unordered list via jquery selectList

After selecting options from the selectList the unordered list looks like this

<ul id="myList">
<li id="3">Cat</li>
<li id="7">Dog</li>
<li id="12">Fish</li>
</ul>

This needs to be done client side via jquery.

What is the best approach to read these values in via querystring in the code behind?

Thanks

Upvotes: 1

Views: 165

Answers (2)

DreamToCode
DreamToCode

Reputation: 291

I solved the issue by looping through the list and appending each value to a variable then assigning the variable to a hidden field. Works fine.

Upvotes: 0

Robin Maben
Robin Maben

Reputation: 23114

You can use a hidden <select multiple="multiple"> with all the options as option items. And set all of them to selected="selected".

That way, all your values get serialized in the query string as a=10&b=12... and so on.

Upvotes: 1

Related Questions