www.webdeveloper.com
Results 1 to 3 of 3

Thread: Search form code with options and hidden filed problem

  1. #1
    Join Date
    May 2010
    Posts
    1

    Question Search form code with options and hidden filed problem

    Hello,

    I am hoping someone can help me with following search form.

    As you can see I have created a form but I don't know how to fix the coding so when a user select a category it will add a different hidden filed for that option for example:
    When the user selects category "Men" the hidden filed
    Code:
    <INPUT TYPE="HIDDEN" NAME="REFERRER" VALUE="http://men.com/acatalog/">
    automaticly will be added the search



    and when the user selects category "Kids" the hidden filed
    Code:
    <INPUT TYPE="HIDDEN" NAME="REFERRER" VALUE="http://kids.com/acatalog/">
    automaticly will be added the search



    and so on...

    Here is my form coding I am using:
    Code:
    <form name="simplesearch" method="get" action="" onsubmit="ssite=document.getElementById('sitelist');this.action=ssite.options[ssite.selectedIndex].value;return true;">			
     		<input type="hidden" name="page" value="search" />
            <input type="hidden" name="PR" value="-1" />
            <input type="hidden" name="TB" value="A" />
            <input type="hidden" name="NOLOGIN" value="1" /><input align="top" class="main_search_box" name="SS" type="text" value="search for ..." onfocus="this.value='';">
    Search within: 
    <select id="sitelist">
    <option value="">Select Catagory</option>
    <option value="http://kids.com/cgi-bin/ss000001.pl">kids</option>
    <option value="http://men.com/cgi-bin/ss000001.pl">men</option>
    <option value="http://women.com/cgi-bin/ss000001.pl">women</option>
    </select><input type="submit" class="button" name="ACTION" value="Go!">
    </form>
    Also I have one more question how do I make the "Select Catagory" a Must Choose and if not chosen to give message that say"Please Select a Category"


    Thank you in advance for any help you can give me...
    I am a bigginer so please go easy on me

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    how do I make the "Select Category" a Must Choose
    By not having "Select Catagory"
    alternative:
    Code:
    ssite=document.getElementById('sitelist');
    if(ssite.value=='') {
      alert('Please select a category');
      return false;
      }
    else {
      this.action=ssite.value;
      return true;
      }

  3. #3
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by emb View Post
    Also I have one more question how do I make the "Select Catagory" a Must Choose......

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    >
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    title></title>
    <
    script type="text/javascript">
    <!--
     
    function 
    validateForm(form) {
        if(!
    form.sitelist.selectedIndex 0) {
            
    alert("Please choose a category");
            return 
    false;
        }
         return 
    true;
    }
     
    //-->
    </script>

    </head>
    <body>
     
    <form action="#" method="post" onsubmit="return validateForm(this);">
        
    <div>
           <select id="sitelist">
                <option value="">Select Catagory</option>
                <option value="http://kids.com/cgi-bin/ss000001.pl">kids</option>
                <option value="http://men.com/cgi-bin/ss000001.pl">men</option>
                <option value="http://women.com/cgi-bin/ss000001.pl">women</option>
                </select>
                <input type="submit" class="button" name="ACTION" value="Go!">
        </div>

    </form>
    </body>
    </html> 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles