Forum Moderators: open

Message Too Old, No Replies

Javascript - window.location & Request.Form("")

Javascript - window.location & Request.Form("")

         

richwangler

9:51 pm on Nov 19, 2002 (gmt 0)

10+ Year Member



Below is an example of what I am trying to complete. What I've noticed is that when I catch a combo box change (via the onchange event) and then utilize window.location to submit the form I am unable to reference Request.Form("") to retrieve form parameters. Am I doing something incorrectly or is this just a limitation? I am aware that I could stick everything into a QueryString but the info I am trying to pass in the real world could conceivably go over the 2000 char permittable IE URL length. I mucked up some code below to give you an idea of what my code kinda looks like if my explanation was insufficient. Thanks in advance!

--------------------------

<HEAD>
<SCRIPT>
function go(){
window.location='theSamePage.asp';
}
</SCRIPT>
</HEAD>
.
.<other code goes here>
.
<*
'sComboEntry doesnt ever seem to get valued!
Dim sComboEntry
sComboEntry = Request.Form("myComboBox")
*>
<FORM Name='myForm' Method='POST' Action=''>
<SELECT Name='myComboBox' onChange=go();>
<OPTION VALUE='val1'>Combo Box Entry 1
<OPTION VALUE='val2'>Combo Box Entry 2
</SELECT>
</FORM>
.
.<other code goes here>
.

txbakers

10:03 pm on Nov 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, it looks like you never include the value of the combo box in your function.

Also, you never submit the form, so there is no "Request.Form" to read.

In order to generate the Request.form, the form has to be submitted.

What are you trying to do with this code? Redirect a page based on the select box? If so, there are other ways to do it.

Also, this question might have more response in the Microsoft ASP forum. I'll ask to move it there.

RossWal

10:15 pm on Nov 19, 2002 (gmt 0)

10+ Year Member



I second txbakers comments on the need to submit the form to be able to retrieve its values on the server. In the go() function you could try replacing window.location with document.forms[0].submit() or myform.submit().... can't remember the exact syntax but some variation of the above should fly.

BTW, I like to close my <option> tags with </option>.

txbakers

10:39 pm on Nov 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BTW, I like to close my <option> tags with </option>.

Yes, this is important. Although technically not required, if you leave them off it wreaks havoc on the macintosh.

richwangler

2:57 pm on Nov 20, 2002 (gmt 0)

10+ Year Member



Thank you for your help. Using the onChange=myForm.submit(); is exactly what I was trying to accomplish. + now it works.

Also didnt know that not closing an option tag really mattered....will do.

later!