Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6024257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:07:44+00:00 2026-05-23T04:07:44+00:00

I desperately need to have my search form’s default input text to change based

  • 0

I desperately need to have my search form’s default input text to change based on the user’s selection in the form’s select input. The current default input text is Enter Keywords… and stays the same no matter what option is selected. What I want, for example, is when the user selects “Employee Directory” to have the default input text for the search field to change to Enter Employee’s First Name…


This is the desired input fields for each selection:

“Website” = Enter Keywords…

“Employee Directory” = Enter Employee’s First Name…

“Publications Center” = Enter Publication’s Information…


Here is my code as it sits currently:

<script type="text/javascript">
    function dosearch() {
    var sf=document.searchform;
    var submitto = sf.engines.options[sf.engines.selectedIndex].value + escape(sf.s.value) + ((sf.engines.selectedIndex=='1')?('&cat=29'):(''));
    window.location.href = submitto;
    return false;
    }
</script>



<form name="searchform" class="search" method="get" onSubmit="return dosearch();"> 

    <select class="engines" name="engines" id="el08">
        <option value="/?s=" selected>Website</option>
        <option value="/?s=">Publications Center</option>
        <option value="/employee-directory?query=name&contact_dir_s=">Employee Directory</option>
    </select>

    <input name="s" class="input" type="text" value="Enter Keywords..." onfocus="if (this.value == 'Enter Keywords...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter Keywords...';}" size="18" maxlength="50"> 

    <input type="submit" name="searchsubmit" class="button" value="Go" />

 </form>

Anybody with the expertise to help code this or offer suggestions, please do! Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:07:45+00:00Added an answer on May 23, 2026 at 4:07 am

    Updated with code that actually works (only tested in IE). This version notes when the selected search option changes and then updates the input if it was displaying the default prompt that went with the previously selected search option.

    <body onload="setDefault();">
    <form name="searchform" class="search" method="get" onSubmit="return dosearch();">
       <select class="engines" name="engines" id="el08" onchange="setDefault();">
           <option value="/?s=" selected>Website</option>
           <option value="/?s=">Publications Center</option>
           <option value="/employee-directory?query=name&contact_dir_s=">Employee Directory</option>
       </select>
       <input name="s" id="searchBox" class="input" type="text" value="" onfocus="myFocusHandler(this);" onblur="myBlurHandler(this);" size="18" maxlength="50">
       <input type="submit" name="searchsubmit" class="button" value="Go" />
    </form> 
    </body>
    <script>
    function myFocusHandler(textField) {
       if (textField.value == defText)
          textField.value = "";
    }
    
    function myBlurHandler(textField) {
        if (textField.value == "")
           textField.value = defText;
    }
    
    var defText;
    var defOptions = {
          "Website" : "Enter keywords...",
          "Employee Directory" : "Enter employee's first name...",
          "Publications Center" : "Enter Publication's Information..."
          // and any other options you may need
          };
    
    function setDefault() {
       var sel = document.getElementById("el08"),
           input = document.getElementById("searchBox"),
           prevDefText = defText;
    
       defText = defOptions[sel.options[sel.selectedIndex].text] || "Enter search term...";
       if (prevDefText == undefined || input.value == prevDefText)
          input.value = defText;
    }
    </script>
    

    Could cut down on use of globals by using a variation of the module pattern or something, but that’s an issue for another day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have build a web application in Zend Framework and now desperately need a
I have an old project from the 1990's I desperately need to compile. The
I am new in this field and i desperately need some guidance from u
I started using django framework just a few days ago and i desperately need
trying desperately to combine 2 simple answers into specifically what i need. sql loop
I'm desperately trying to solve this one. I have a bunch of files stored
Google is failing me here. I have a designer who needs desperately to have
I desperately need help with a query that's been causing a lot of grief
I've been trying desperately to get my application (15 C# dlls and 1 C++/CLI
I'm desperately searching for a tool allowing me to copy documents with their old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.