SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy javascript show hide menu

    hi, i was searching the google when i came across this website, i have searched this website throughly to find my solution but got a little hint as i am bery basic to javascript:

    what i wanna achieve is:

    putting two radio buttons and with already selected as AUTHOR and it should not show the drop down which is based on this selection of radio buttons, if i choose Others, a drop down should papulate from the backend query..

    i tried it something like this:

    HTML Code:
    <input name="ownerproperty" type="radio" value="1" onclick="sho(form1.ownerproperty)" />
                                    Other<br />
                                    <input name="ownerproperty" type="radio" value="0" onclick="sho(form1.ownerproperty)" />
                                    Authors
    Then in the javascript, it is handling as:
    HTML Code:
    <script language="javascript1.2">
    								function sho(ownerproperty)
    									{
    									for (var i=0; i < document.form1.ownerproperty.length; i++)
    									   {
    									   if (document.form1.ownerproperty[i].checked)
    										  {
    										  var rad_val = document.form1.ownerproperty[i].value;
    										  }
    									   }
    									if(rad_val==1)
    									{
    									document.getElementById("owner").style.visibility="visible";
    									}
    									else if(rad_val==0)
    									{
    									document.getElementById("owner").style.visibility="hidden";
    									}
    									}
    					</script>
    <select name="owner" id="owner">
    <option value="0">gavy</option>
    </select>

    it worked, but it comes up with already showing a drop down while no value from radio button is selected, if i toggle between the values, then i run perfectly..


    means for the very first time it does not work as i want it to do?

    Any help will be appreciated

    Thanks
    Last edited by gavy; Dec 18, 2007 at 07:06. Reason: f

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Add the attribute onload="sho(document.form1.ownerproperty)" to the body element and checked="checked" to the Author input.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


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
  •