SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select option value with "other" when usesr select when input filed

    Hi,
    I'm looking to accomplish in the Form when user select "others" from the select options , want pop up java windows user to field in the information.

    here there simple form code

    <form>
    <select>
    <option value="others">Others</option>
    </select>

    The field to ask where do you hear about us? I have list of options in there but when the user select "others" i want to input filed popup and want user to filed in the info.

    Any advice on the javascript?

    Thanks,
    Sam

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want a window to be popped up? Or you just want to appear another text box just next/below the select box? I would just show a text box below the select if others is selected.
    Code html4strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    	<meta name="author" content="Raju Gautam" />
    	<title>Untitled 1</title>
        <script type="text/javascript">
        window.onload = function(){
            var selBox = document.getElementById('sel');
            selBox.onchange = function(){
                if(this.value == 'others'){
                    document.getElementById('divother').style.display = 'block';
                }
                else{
                    document.getElementById('divother').style.display = 'none';
                }
            }
        }
        </script>
    </head>
    <body>
        <form>
        <select name="sel" id="sel">
            <option value="">Select</option>
            <option value="google">Google</option>
            <option value="others">Others</option>
        </select>
        <div id="divother" style="display: none;"><input type="text" name="othertext" id="othertext" size="25" /></div>
    </body>
    </html>
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx Ruju..

    How about pop up window?

    Thanks for the help..

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want popup window then you need extra work to transfer the value from pop up window to your parent window. Rather you can use prompt() JavaScript method instead. I don't know what type of pop up window you want, if you want a window itself then you need to open with a different file with window.open('filename.html','NewWindow', '') as far as I know. But whatever you do at least you should have a field (hidden or visible text box) to store the entered value for others.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Ruj, just wanted thanks you for your help.
    Just being busy. Thanks for the advice. It kind of give me the right direction.


Bookmarks

Posting Permissions

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