I use a html nested unordered list that is called as a dropdown. When a tag tag is clicked inside an element of the list of internal lists, it runs some javascript, which should set the value of the hidden field in the text for the link that the button was clicked on.
It seems javascript is working - I used a warning to read the value from a hidden field, but then when I try to put that value in a querystring in my asp.net C # code behind - it pulls the initial value - not the javascript value.
I assume this is because javascript is the client side, not the server side, but does anyone have an idea how I can get this working
HTML
<div class="dropDown accomodation"> <label for="accomodationList">Type of accomodation</label> <ul class="quicklinks" id="accomodationList"> <li><a href="#" title="Quicklinks" id="accomodationSelectList">All types </a> <ul id="sub" onclick="dropDownSelected(event,'accomodation');"> <li><a href="#" id="val=-1$#$All types" >All types</a></li> <li><a href="#" id="val=1$#$Villa" >Villa</a></li> <li><a href="#" id="val=2$#$Studio" >Studio</a></li> <li><a href="#" id="val=3$#$Apartment" >Apartment</a></li> <li><a class="last" href="#" id="val=4$#$Rustic Properties" >Rustic Properties</a></li> </ul> </li></ul> </div> <input type="hidden" ID="accomodationAnswer" runat="server" />
Javascript
if(isChildOf(document.getElementById(parentList),document.getElementById(targ.id)) == true) { document.getElementById(parentLi).innerHTML = tname; document.getElementById(hiddenFormFieldName).Value = targ.id; alert('selected id is ' + targ.id + ' value in hidden field is ' + document.getElementById(hiddenFormFieldName).Value); }
C # code
String qstr = "accom=" + getValFromLiId(accomodationAnswer.Value) + "&sleeps=" + getValFromLiId(sleepsAnswer.Value) + "&nights=" + getValFromLiId(nightsAnswer.Value) + "®ion=" + getValFromLiId(regionAnswer.Value) + "&price=" + Utilities.removeCurrencyFormatting(priceAnswer.Value);
source share