dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Search form code with options and hidden filed problem

  1. #1
    Join Date
    May 2010
    Posts
    2

    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 to 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
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Search form code with options and hidden filed problem

    That's impressive, a thread with a 5 star rating when it hasn't even had any replies yet and isn't even in the right forum

    @emb: javascript is not java, you need the client side scripting forum. I'll ask the mods to move it for you.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    May 2010
    Posts
    2

    Red face Re: Search form code with options and hidden filed problem

    Thank you, sorry about that did not see it Java Programming...

  4. #4
    Join Date
    May 2010
    Posts
    3

    Re: Search form code with options and hidden filed problem

    if your hidden input field is in the form then you can use javascript code like
    Code:
     ssite=document.getElementById('sitelist');
     document.simplesearch.REFERRER.value = ssite.options[ssite.selectedIndex].value;
    Make sure you do this before the form is submitted. Else the value of hidden element will not be set.

    If your hidden element is not in the form, add an 'id' attribute to it and refer to it as document.getElementById('REFERRER');

    Hope this helps.

    And this for sure needs to be in javascript forums. Nothing to do with java except for the name.substring()!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)