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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Javascript OnBlur() - Add to QueryString

    Hi All,

    I was wondering if it is possible to use Javascript to add the value from a form textbox field to the QueryString, perhaps using the OnBlur event?

    Basically, I'm looking for something similar to the dropdown box system that uses the OnChange event to redirect to a url assigned to the selected dropdown value. Can this be done with a textbox field, rather than a dropdown?

    Example code would be welcomed.

    Thanks,
    JimboF

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    is it this of any help? (Frankly, I didn't uderstand the onblur ideea)
    [php]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <script>
    function gourl(a){
    alert(a);
    location.href='http://'+a;
    }
    </script>
    </head>
    <body>
    <form>
    http://<input name="url" type="text"><input type="button" value="Go URL" onclick="gourl(this.form.url.value)">
    </form>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    script>
    function 
    gourl(a){
    alert(a);
    location.href='http://'+a;
    }
    </script>
    </head>
    <body>
    <form>
    http://<input name="url" type="text"><input type="button" value="Go URL" onclick="gourl(this.form.url.value)">
    </form>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    May 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Kor,

    Thanks for the suggestion but not quite what I was looking for. I'll try to explain myself a little better below.

    For example I have the folowing search form:

    <form name="SearchDB" method="GET" action="Search.asp">
    <tr>
    <td valign="middle" width="136"><font size="2" face="Verdana"><b>Keyword(s):</b></font></td>
    <td valign="middle" width="314"><input type="text" name="keywords" size="30"></td>
    </tr>
    </form>

    What I would like to happen is:

    1) someone enters in a keyword into the keywords form field to search the database.

    2) after they move the cursor to another part of the form (i.e., there are other options that can be selected on the search form) then the keyword(s) are automatically added to the QueryString with out the user doing anything (i.e., through a page refresh triggered by an OnBlur event perhaps).

    Essentially, what I'm looking for is a javascript that will grab the keyword value, add it to a URL string + the QueryString variable (something like Search.asp?keywords=Thanks for the help&records=1") and then refresh the page with this new URL.

    Below is the similar Dropdown box code I mentioned in the previous post:

    <select size="1" name="records" onChange="window.location=document.Records.records.options[document.Records.records.selectedIndex].value">
    <option value="Search.asp?keywords=&records=">Choose One</option>
    <option value="Search.asp?kewyords=&records=25" <% If Request.QueryString("records") = "25" Then Response.Write " selected" End If%>>25</option>
    <option value="Search.asp?keywords=&records=50" <% If Request.QueryString("records") = "50" Then Response.Write " selected" End If%>>50</option>
    </select>

    What happens here is that when an option is selected, say 25, then the OnChange event jumps to the URL given in the Option Value, thus updating the Querystring with the correct value for "records".

    Is something similar possible for a Textbox?

    Thanks for the help!

    Cheers,
    JimboF

  • #5
    New to the CF scene
    Join Date
    May 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I played around a little bit with this and the following seems to work. Thought I would post it in case anyone else is interested.

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Database Search</title>

    <script language="JavaScript">
    function KeyWdQS(){
    var key=document.SearchDB.keywords.value
    if(key != "") {
    url="Search.asp?keywords=" + key
    document.location.href=url;}
    }
    </script>
    </head>

    <body>
    <form name="SearchDB" method="GET" action="Search.asp">
    <tr>
    <td width="36" valign="middle"><b> <font size="2" face="Verdana">
    Keyword(s</font><font size="2" face="Verdana">):</font></b></td>
    <td valign="middle" width="314">
    <input type="text" name="keywords" size="30" onblur="javascript:KeyWdQS()"></td>
    <td valign="middle" width="36">&nbsp;</td>
    </tr>
    </form>
    </body>
    </html>

    Cheers,


  •  

    Posting Permissions

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