Link to home
Start Free TrialLog in
Avatar of wobbled
wobbledFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Onchange event to write value to ASP Variable

I have a simple select form option.  Using the OnChange event I wish to write the selected value into an ASP variable which has been declared earlier.

The ASP variable is: uDisplay

here is the select statement

                 
              <select id="ResultsPerPage" name="ResultsPerPage">
              <option value="10">10</option>
              <option value="20" selected="selected">20</option>
              <option value="50">50</option>
              <option value="100">100</option>
                  </select>
ASKER CERTIFIED SOLUTION
Avatar of Gibu George
Gibu George
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of b0lsc0tt
wobbled,

The ASP variable isn't there any more.  Once the ASP script is processed the variable is gone.  An exception is server variables but the html page and the onchange event would need to send a request back to the server to modify it.  Javascript is a different language from ASP and runs at a different time (i.e. server vs. clientside).  To do anything in ASP you need ASP script.  The submit option the expert mentioned above could call an ASP page that could then modify the session variable (or a new one).  Another option would be to use AJAX (Javascript code that sends a request to the server WITHOUT refreshing the page).  Keep in mind the basic issue I mentioned at the start though.  Please clarify the type of variable and respond to what I provided if you are interested in details on either method.

Let me know if you have any questions or need more information.

b0lsc0tt
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wobbled

ASKER

Cheers guys thanks for your help on this.  b0lsc0tt  - I have quite a lot of ASP code on the page and depending on what the user selects in the drop down, I wanted to refresh the data on that page then use the selected number to feed into the paging options.  I have decided to go down the hidden form field route you suggested.

Gibu - I have halved the points as you answered the question on how to call a javascript function from onChange.  Thanks
Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
p.s.  I have pasted the Grading Comments below since they may be useful to others who view this question.  Right now EE shows them to only the Asker and participants with an Accepted/Assisted comment.

Cheers guys thanks for your help on this. b0lsc0tt - I have quite a lot of ASP code on the page and depending on what the user selects in the drop down, I wanted to refresh the data on that page then use the selected number to feed into the paging options. I have decided to go down the hidden form field route you suggested.
 
Gibu - I have halved the points as you answered the question on how to call a javascript function from onChange. Thanks

Open in new window