Nested if with document.write()s

K

Ken

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top