SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: javascript form

  1. #1
    SitePoint Enthusiast alexvgtb's Avatar
    Join Date
    Feb 2003
    Location
    Brussels, Belgium
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript form

    See here :

    http://villers.customer.attikh.net/~...rum/index2.php

    Sorry, it's all in French.

    I would like that when "Un événement" is selected in the first menu then and only then the last box appears with the date.

    Currently the date box is always there.

    Doable in Javascript ? I bet so ! But I don't know how :-(

    Who can help me with this ?

  2. #2
    SitePoint Enthusiast alexvgtb's Avatar
    Join Date
    Feb 2003
    Location
    Brussels, Belgium
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OnChange ? OnFocus ? Anyone ?

  3. #3
    SitePoint Enthusiast alexvgtb's Avatar
    Join Date
    Feb 2003
    Location
    Brussels, Belgium
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...

    This does not work !

    Code:
     
    <script>
    function show(object)
    {
    if (document.layers && document.layers[object])
    	{ 
    	document.layers[object].visibility = 'visible';
    	} 
    else if (document.all)
    	{
    	document.all[object].style.visibility = 'visible';
    	document.all[object].style.zIndex = 100;
    	}
    else if (document.getElementById) 
    	{
    	document.getElementById(object).style.visibility = 'visible';	 document.getElementById(object).style.zIndex = 100; 
    	} 
    }
    function hide(object)
    {
    if (document.layers && document.layers[object])
    	{ 
    	document.layers[object].visibility = 'hidden';
    	} 
    else if (document.all)
    	{ 
    	document.all[object].style.visibility = 'hidden';
    	}
    else if (document.getElementById) 
    	{
    	document.getElementById(object).style.visibility = 'hidden'; 
    	} 
    }
    </script>
     
     
    <form name="form" action="searchquery.php" method="get"> 
    <select name="cat" size="6" multiple>
    <option selected value="1" >une abbaye</option>
    <option value="2" onSelect="show('txtNom')" onBlur="hide('txtNom')">un événement</option>
    <option value="4">un colloque / une conférence</option>
    <option value="3">un h&eacute;bergement</option>
    <option value="5">un produit artisanal</option>
    </select>
    <span id="txtNom" style="visibility: hidden;">This should appear on select</span><br>

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    get rid of the document.layers and document.all references or at leat move the document.getElementById references in front of them. The number of people using IE4 (document.all) and Netscape 4 (document.layers) is insignificant to the number of people using IE5+, Netscape 6+, Firefox, Opera, Safari, Konqueror, etc all of which support document.getElementById

    Also you can't attach Javasctript to the <option> you need to attach it as an onchange to the <select> and then test for what is selected.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •