Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.location problems

    Hi All - have the following code which I am trying to have re-direct the user to a page (in the same window) dependant on what they enter into one of the text fields. At the same time it is ading the info from the text field to a database (not sure if this effects anything).
    Just can't seem to get it to work (althought I can get it to work using window.open) ???

    Can some one let me know where I am going wrong - cheers.

    <script language="JavaScript">
    // <!--

    function page_shift(f)
    {
    var deal_no1 = f.elements["dealno"].value;
    var deal_no = (deal_no1.substring(0,2));
    var page_url = "typical.asp?id="
    var page_jump = page_url + deal_no;
    // alert(page_jump);
    window.location = page_jump;
    }

    // -->
    </script>


    <body>

    <form ACTION="<%=MM_editAction%>" name="dealsearch" method="POST" onSubmit="page_shift(this)">

    <input type="text" size="3" name="dealno" maxlength="4">&nbsp;<input name="" type="submit" value="Go">

    <input type="hidden" name="MM_insert" value="dealsearch">
    </form>

    </body>

    Appreciate the help.
    BVT.

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    maybe
    window.location.replace(page_jump);
    Shawn

  • #3
    New Coder
    Join Date
    Jun 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nope - didn't seem to work.

    Thanks anyway...
    BVT.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can't submit the page and redirect to a different page at the same time at the same window. You must redirect to a new window. But why not put the redirection in the MM_editAction page?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Jun 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Glenn,

    I need to add the first 2 digits from the text field to the URL - ie. typical.asp?id= + the 2 digits thus giving - typical.asp?id=12.

    Not sure how to add to the <%=MM_editAction%> but only take the first 2 digits (its a 4 digit field).

    Cheers
    BVT.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can do the string manipulation in the server-side.
    Code:
    dealnum = request.form("dealno")
    if len(dealnum)<>4 then
       'save data to database
    
       'redirect after saving the record
       response.redirect "typical.asp?id=" & mid(dealnum, 1, 2)
    else
      response.write "error in deal number" 
    end if
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New Coder
    Join Date
    Jun 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers Glenn,

    Have sorted it using <%=MM_editAction%> - as per your first suggestion which made me think...

    Appreciated!!
    BVT.


  •  

    Posting Permissions

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