简体   繁体   中英

How do i use an asp.net variable value in javascript

i have a asp.net application. It is assumed that every Bus has a android device which continuously sends its current location to wcf rest service. Now the administrator on the other side needs to monitor the current location of theses buses. I have a dropdow list from where he chooses the bus number. now i need to send this bus number to the wcf service and show the current location on the map I have no clue as to how do i do this. please help. The plotting algorithm is in javascript and i need to use the asp.net variable in java script to plot the current loacation.

to get the dropdownlist value use this code:

    var ddl= document.getElementById("<%= yourDDLId.ClientID %>")
    var select= ddl.options[ddl.selectedIndex].text;

and sometimes it works also if you write only:

    var ddl= document.getElementById("yourDDLId")
    var select= ddl.options[ddl.selectedIndex].text;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM