Click here to Skip to main content
15,881,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have the folowing html code :
HTML
<select name="myselect" id="myselect" >
    <option value="2">3 luni  - pret = 15$</option>
    <option value="4">6 luni  - pret = 30$</option>
    <option value="6">1 an    - pret = 60$</option>
    <option value="8">5 ani   - pret = 250$</option>
    <option value="10">PeViata - pret = 500$</option>
</select>

Each time when the item changes I want to call a function from my aspx.cs file.
I really don't know how to do this (this is my first app using asp.net) .
I thought that I could call a js function when the item is changed . below is my js function.
JavaScript
function selectorFunction() {
        var x = document.getElementById("myselect").value;
        <% selectPrice(Convert.ToInt32(x)); %>
}

The issue with this function is that var x does not exists in that context.
Can you please help me figure out how can I call a function from my aspx.cs file when a different item is selected.

Thank you in advance.
Posted
Updated 11-Dec-14 0:24am
v2
Comments
Sinisa Hajnal 11-Dec-14 6:48am    
Look at jQuery ajax method. Create WebMethod in your page and call it with ajax call. There are plenty of tutorials for this, google "asp.net webmethod ajax" and you'll find it.
Radu_Socaciu 11-Dec-14 6:49am    
Thank you for your quick reply.
Kornfeld Eliyahu Peter 14-Dec-14 2:56am    
Learn WebMethods...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900