Create a search function on a web page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dr3am3rz
    New Member
    • May 2007
    • 4

    #1

    Create a search function on a web page

    Hi guys, I have a problem here. I have created a textbox and a button for search function, how do I get it to work without using forms?

    Here is the code:

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Public Folder Help Desk</title>

    <script id=clientEventH andlersVBS language=vbscri pt>

    <!--

    Sub cmdSearch_oncli ck



    End Sub

    -->
    </script>

    </head>

    <body>
    <input type="text" name="txtSearch " size="18" tabindex="2">

    <input type="button" value=" Search " name="cmdSearch " tabindex="3">

    </body>

    </html>

    What must I enter in the Sub cmdSearch_oncli ck if I want to get the value where the user enters in the textbox?
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    vbscript will only run in IE. Here's an example using Javascript.

    [CODE=html]<html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Public Folder Help Desk</title>

    <script language=javasc ript>

    function search() {
    window.location ="http://www.google.com/search?q=" + window.escape(d ocument.getElem entById('txtSea rch').value)
    }

    </script>

    </head>
    <body>
    <input type="text" id="txtSearch" name="txtSearch " size="18" tabindex="2">
    <input type="button" value=" Search " onclick="search ();" name="cmdSearch " tabindex="3">

    </body>

    </html>[/CODE]

    Comment

    • Dr3am3rz
      New Member
      • May 2007
      • 4

      #3
      Hmm. You say vb only run in IE? Isn't it suppose to run on IE or vb in HTML codes doesn't run for Outlook? Must I really use Javascript instead of VB? Sorry for lots of question because I'm new to these things. Thanks in advance.

      Comment

      • Dr3am3rz
        New Member
        • May 2007
        • 4

        #4
        Ah.. Sorry, I tested out the code you post it here, the search function is working but I'm creating the search function for searching Outlooks item.

        Comment

        • Dr3am3rz
          New Member
          • May 2007
          • 4

          #5
          Is there any one can help me here? VB script will be preferred. My textbox is created in the <body> but my VB statement all is done in the <script> and I can't get to reach the textbox as in there's error showing that "txtSearch" cannot found. Please help, urgent. Thanks alot. Here's the code:

          <html>

          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
          <title>Public Folder Help Desk</title>

          <script id=clientEventH andlersVBS language=vbscri pt>

          <!--

          Sub cmdSearch_oncli ck

          (What statement should I put in here in order to make the search function works? And how can I get the data value that the user enter in the search textbox in the <body>? )

          End Sub

          -->
          </script>

          </head>

          <body>
          <input type="text" name="txtSearch " size="18" tabindex="2">

          <input type="button" value=" Search " name="cmdSearch " tabindex="3">

          </body>

          </html>

          Comment

          Working...