why won't this work?

Results 1 to 5 of 5

Thread: why won't this work?

  1. #1
    surfrjohn Guest

    Default why won't this work?

    I have a page with a form. I want the form to be empty if the page is called with a QueryString variable, and I want it populated if tha page is called with a Form variable. So I wrote my code like this (I use Javascrip):<BR><BR>if (Request.QueryString("ID") != "") {<BR> userID = Request.QueryString("ID");<BR> newORupdate = "new";<BR>}<BR>else if (Request.Form("ID") != "") {<BR> userID = Request.Form("ID");<BR> newORupdate = "update";<BR><BR>But this doesn&#039;t work! Is there a generic way to tell if the page was called by QS or by Form (i.e., testing whether either is null)?? It seems like using an if...else if only works if I&#039;m testing for the same variable within each clause, but that doesn&#039;t seem logical.<BR><BR>Thanks for the help!

  2. #2
    fsm Guest

    Default RE: why won't this work?

    Instead of using request.form("ID") or request.querystring("ID"), just use request("ID"). This searches the Querystring first, then checks the form variables. pass another variable to determine if it is new or not.

  3. #3
    surfrjohn Guest

    Default server issue?

    I appreciate the help, using Request("ID") did help.<BR><BR>However, I&#039;m still having major issues with resolving new or update. To determine this, for updates I pass an additional id through the form that I do not pass using the QS. Therefore, in my code I check for whether this value is undefined or not. If the page is called by QS, it should be undefined, toherwise it should have a value. But this code won&#039;t evaluate properly!!!<BR><BR>if (currentID == "undefined") {<BR>do this...<BR>}

  4. #4
    surfrjohn Guest

    Default server issue? 2

    opps, I submitted by mistake...<BR><BR>For this code:<BR><BR>if (currentID == "undefined")<BR><BR>I actually get an ASP server error that says currentID is undefined! How can this happen if that&#039;s what I&#039;m checking for?? I mean, I&#039;m asking it if it&#039;s undefined, yet it won&#039;t process my statement, it kicks out an error!

  5. #5
    Join Date
    Dec 1969

    Default RE: server issue? 2

    you are asking if currentID is equal to a string with the value "undefined".<BR><BR>you need to do something like:<BR><BR>if(new String(currentID)=="undefined")<BR>or<BR>if(typeof (currentID)=="undefined")

Posting Permissions

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