SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    right here
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question (document.write)writing on the same window using events??

    hi folks,
    cant figure out how to write on the same window on an event load. document.write opens a new window automatically.

    this is wat i want:
    i've got 7 links of 7 days in a week. and when the user clicks one link, it should display the schedule beneath that link or in any table somewhere in the page. ive searched a lot on the web, and from what i've found, doesnt seem like that its possible!. maybe if we use the div tags and then pass divnames as arguments to the calling function.but tat i dont know how to hide the contents of div because that is also shown on the window..

    everytime i click the link..it shows the contents in the new window!!

    any solution, suggestions would be highly appreciated.

    thanks in advance,

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    newyork
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey, using document.write() will, by default write the text in a new window. this is some code i use to display new text in the same page using <div>'s and hiding them untill called. its probably very amatuer and unprofessional but it gets the job done for me. hope it helps...

    <html>
    <head>
    <title>days</title>

    <script>
    function changeDay(newDay)
    {
    for (i = 1; i <= 7; i++)
    {
    document.getElementById(i).style.display="none";
    }

    var day = document.getElementById(newDay);

    if (day.style.display=="none")
    {
    day.style.display="";
    return;
    }
    }
    </script>

    </head>
    <body>
    <table width="700" border="0">
    <tr>
    <table width="700" border="1">
    <tr>
    <td onclick="changeDay(1)" width="100">Sunday</td>
    <td onclick="changeDay(2)" width="100">Monday</td>
    <td onclick="changeDay(3)" width="100">Tuesday</td>
    <td onclick="changeDay(4)" width="100">Wednesday</td>
    <td onclick="changeDay(5)" width="100">Thursday</td>
    <td onclick="changeDay(6)" width="100">Friday</td>
    <td onclick="changeDay(7)" width="100">Saturday</td>
    </tr>
    </table>
    </tr>

    <tr>
    <td width="100">
    <div id="1" style="display: none">
    Sunday's info here
    </div>
    <div id="2" style="display: none">
    Monday's info here
    </div>
    <div id="3" style="display: none">
    Tuesday's info here
    </div>
    <div id="4" style="display: none">
    Wednesday's info here
    </div>
    <div id="5" style="display: none">
    Thursday's info here
    </div>
    <div id="6" style="display: none">
    Friday's info here
    </div>
    <div id="7" style="display: none">
    Saturday's info here
    </div>
    </td>
    </tr>
    </table>
    </body>
    </html>

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    right here
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Thanks ..works very nicely

    thanks a lot for the help...works gr8

    just added an empty href link to change the cursor...

    <a href=#> Sunday </a>

    just creates a link pointing no where.

    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
  •