is there a difference in getting vars with jscript

Results 1 to 3 of 3

Thread: is there a difference in getting vars with jscript

  1. #1
    Mark Guest

    Default is there a difference in getting vars with jscript

    Im having the worst trouble getting these variables in serverside javascript.<BR><BR>in VBScript, I always use this to catch the same variable:<BR>if request.form("thisvar") = "" then<BR> s = request.querystring("thisvar")<BR>else <BR> s = request.form("thisvar")<BR>end if<BR><BR>But in javascript, that just won&#039;t work. Im using correct javascript notation I believe. It throws errors, grabs one but not the other.. Im getting a freakin headache over this... anyone know whats going on??? <BR>heres the javascript code:<BR><BR>if ( Request.Form ( &#039;action&#039;) == &#039;&#039; ) <BR> var action = Request.queryString ( &#039;action&#039;)<BR>else <BR> var action = Request.Form ( &#039;action&#039;)

  2. #2
    Join Date
    Dec 1969

    Default Dump the var declaration...

    I&#039;m *pretty* sure that the problem is that you create the var either after the if or after the else and then, by the time you get to the next statement, that variable is gone.<BR><BR>Move the var declaration *ahead* of the if...else.<BR><BR>Thus:<BR><BR>var action;<BR>if ( Request.Form ( &#039;action&#039;) == &#039;&#039; ) <BR>&nbsp; &nbsp; action = Request.queryString ( &#039;action&#039;)<BR>else <BR>&nbsp; &nbsp; action = Request.Form ( &#039;action&#039;)<BR><BR>HOWEVER...<BR><BR>Wh y do you bother doing this????<BR><BR>Why not simply:<BR>&nbsp; &nbsp; action = Request(&#039;action&#039;)<BR><BR>???<BR><BR>It&# 039;s true that making the system figure out whether a QueryString or a Form is involved is a *little* slower, the system is *surely* a lot faster than you making *TWO* calls (and an if test!) trying to figure it out on your own!<BR><BR>

  3. #3
    mark Guest

    Default this is the stuff I dont learn in school

    thanks... for both answers.. especially the second one!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts