SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with simple DHTML script

    Hi there.

    I need help with the script found at

    www.hiphopmusic.co.uk/js.html

    I want it so that if you click the "one off" radio button, the top box is visible and the bottom box is invisible, and if you click the "regular" radio button, the top box is invisible, and the bottom box is visible.

    Thanks in advance,
    J

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your problem is that you're telling one span tag to hide but you're never telling the other one to display itself, and vice versa. i don't have time to post a solution but if i have time later i will. its pretty straight forward, though.

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o.k., here you go. i noticed in your code you handn't included the basic tags...<html><head><body>...at a minimum you've got to have those in there:

    <html>
    <head>
    <script language="javascript">

    function displayForm(iNumShow, iNumHide) {
    var sWhichSpanShow = "divt" + iNumShow;
    var sWhichSpanHide = "divt" + iNumHide;

    document.all(sWhichSpanHide).style.visibility = "hidden";
    document.all(sWhichSpanShow).style.visibility = "visible";

    }
    </script>
    </head>
    <body>
    <span id="divt1" style="visibility:visible;position:relative;top:0;left:0">
    <form action="javascript:#">
    Type 1 Input: <input name="t1" type="text" value="">
    </form>
    </span>
    <form>
    one off <input name="r1" type="radio" checked value="" onCLick="displayForm(1,2)">
    regular <input name="r1" type="radio" value="" onCLick="displayForm(2,1)"><BR>
    </form>
    <span id="divt2" style="visibility:hidden; position:relative; top:0;left:0;">
    <form action="javascript:#">
    Type 2 Input: <input name="t2" type="text" value="" >
    </form>
    </span>
    </body>
    </html>


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
  •