Nested if with document.write()s

Discussion in 'Javascript' started by Ken, Sep 25, 2004.

  1. Ken

    Ken Guest

    How do I nest a second if(status2) inside the document.write(status1)?

    I would like to add the 2nd if(status2) if to the 1st script (status1) so
    the picture is removed if status2 = inactive and looks like the 2nd table.
    Can this be done?

    Ken

    <body>
    <script type="text/javascript">
    var status1 = "active";
    var status2 = "inactive";
    var Picture = "Logo";
    var Name = "Name";
    var Note = "This is the info";
    var Price = 10.25;
    </script>

    <script type="text/javascript">
    if (status1 == "active") {
    document.write('<table cellspacing="0" cellpadding="0" border="1"
    width="100%"><tr><td rowspan="3">1' + Picture + '</td><td width="5"
    rowspan="3">2&nbsp;</td><td>3' + Name + '</td></tr><tr><td>4' + Note +
    '</td></tr><tr><td>5Price = $' + Price + '&nbsp;&nbsp;<a
    href="1a.htm">Click</a></td></tr></table><br><br>') }
    </script>

    <script type="text/javascript">
    if (status2 == "inactive") {document.write('6No picture')}
    </script>

    <br><br>
    <table cellspacing="0" cellpadding="0" border="1" width="100%"><tr><td
    width="5" rowspan="3">2&nbsp;</td><td align="center" valign="top"
    width="125">1Name</td></tr><tr><td>4Note</td></tr><tr><td>5Price = $Price
    &nbsp;&nbsp;<a href="1a.htm">Click</a></td></tr></table>

    </body>
    Ken, Sep 25, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russ Perry Jr
    Replies:
    2
    Views:
    4,120
    Russ Perry Jr
    Aug 20, 2004
  2. Chad E. Dollins
    Replies:
    3
    Views:
    651
    Kai-Uwe Bux
    Nov 8, 2005
  3. request@no_spam.com
    Replies:
    5
    Views:
    419
  4. jullag
    Replies:
    20
    Views:
    304
    Frances
    Sep 22, 2005
  5. Frank Peterson
    Replies:
    9
    Views:
    225
    David Mark
    Jun 28, 2009
Loading...

Share This Page