0

I have a server variable (VBScript) called selectedOptions. I need to assign it a value based on the value of a select box. Currently I am trying to use Javascript to handle the onchange event of the select box and then pass the selected value to the selectedOptions variable.

function select_touchGloves_onchange()
{
var mySelect = document.getElementById("select_touchGloves");
<% selectedOptions %> = mySelect.options[mySelect.selectedIndex].value; 
}

This code is is giving me a type mismatch error. Can I correct this? Or is there a way I can obtain this value solely with vbscript?

EDIT---------------------------------------------------------------------------------------

This question is no longer what I need - please see the comments below for further information if you are interested.

3
  • you need to pass the value back using an ajax call or something to get it back to the server. Can you explain more about what you're trying to do? when you say vbscript, do you mean an aspx page? Commented Feb 29, 2012 at 4:29
  • Your server-side VBScript, i.e., everything in <% %> tags, will execute on the server when the page is first requested, the results are sent to the browser, and then the client-side JavaScript executes. So you can't assign a value to your VB variables from JavaScript. You can use JavaScript to make another request to your server (preferably but not necessarily with Ajax) to pass the selected item through. What do you want to do with the value? Commented Feb 29, 2012 at 4:37
  • No, it is a classic asp page and I am not experienced in working with classic asp. I want to obtain the value and pass it to a cart that is stored as a session object. Commented Feb 29, 2012 at 4:37

1 Answer 1

1

Your question has problems.

It's confusing concepts ASP server concepts and client concepts.

I recommend that you build at least two pages. One a plain HTML form with a submit button and another the ASP page that processes the form. You ought to follow an ASP tutorial, such as this one: http://www.asptutorial.info/learn/Forms.html.

If you provide more information about the problem your trying to solve, we can tailor an answer that's more suitable for you.

Sign up to request clarification or add additional context in comments.

2 Comments

My avast blocked a trojan on that site after I selected another topic in the drop-down, so I only read the first page. Despite this, I have found enough material to have a bit better of an understanding. The value that I need will actually be posted back to the page after clicking a Add To Cart button. I simply need to obtain that selected value once it is posted back to the same page.
I am currently searching for the code to obtain the posted back value using vbscript but if anyone wants to chime in and help on this one I would be most grateful!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.