...

View Full Version : script/noscript issue



bazz
03-29-2009, 11:44 PM
Hi,

I have utilised noscript, to show a warning to visitors. and my js is (obviously), inside script tags. However, I want my whole js powered code no to show if js is disabled. what tag need I use to achieve this?

bazz

timgolding
03-29-2009, 11:52 PM
Hi,

I have utilised noscript, to show a warning to visitors. and my js is (obviously), inside script tags. However, I want my whole js powered code no to show if js is disabled. what tag need I use to achieve this?

bazz

Something like this


<noscript>
Whatever goes here
</noscript>
<script type="text/javascript">
<!--
Your script code
-->
</script>


its the <!-- and --> that hide your script code when JS is not present

bazz
03-30-2009, 12:12 AM
thanks for the quick response. I guess I should have put this in the js forum so would a mod please move it there. (thanks)

ok, then here is my html output


<noscript>
<p class='warning'>
Please enable Javascript so that you can add extras to your chosen room.
</p>
</noscript>

<script type="text/javascript" language="javascript">
//<![CDATA[

function HidePart(d) { document.getElementById(d).style.display = "none"; }
function ShowPart(d) { document.getElementById(d).style.display = "block"; }
function CheckboxChecked(b,d)
{
if(b) { ShowPart(d); }
else { HidePart(d); }
}
// ]]>
</script>


<input type="checkbox" onclick="CheckboxChecked(this.checked,'Airport Pick-up')" />
Airport Pick-up <br />

<div id="Airport Pick-up" style="display:none">
<table>

<tr>
<td class="right_side">
<input type="checkbox" name="Airport Pick-up" value="Courtesy Car" /> Courtesy Car </td>

<td class="right_side">20.00 GBP</td>
</tr>


<tr>
<td><p></p>
</td>
</tr>
</table>
</div>


I thought 'document.write' might help but it seems not to output it all and therefore messes it up.

code with document.write attempt


<noscript>
<p class='warning'>
Please enable Javascript so that you can add extras to your chosen room.
</p>
</noscript>
<script type="text/javascript" language="javascript">
//<![CDATA[

function HidePart(d) { document.getElementById(d).style.display = "none"; }
function ShowPart(d) { document.getElementById(d).style.display = "block"; }
function CheckboxChecked(b,d)
{
if(b) { ShowPart(d); }
else { HidePart(d); }
}
// ]]>
</script>

-- works fine up to this point.

<script type='text/javascript'>
document.write("<input type ='checkbox' onclick="CheckboxChecked(this.checked, 'Airport Pick-up')" />");
document.write("Airport Pick-up <br />");
document.write(" <div id="Airport Pick-up" style="display:none"><table> ");

<tr>
<td class="right_side">
<input type="checkbox" name="Airport Pick-up" value="Courtesy Car" /> Courtesy Car </td>

<td class="right_side">20.00 GBP</td>
</tr>

<tr>
<td><p></p>
</td>
</tr>
</table></script>

</div>

<script type='text/javascript'>
document.write("<input type ='checkbox' onclick="CheckboxChecked(this.checked, 'Bathing ')" />");
document.write("Bathing <br />");
document.write(" <div id="Bathing " style="display:none"><table> ");

<tr>
<td class="right_side">
<input type="checkbox" name="Bathing " value="Bath Robes - Luxurious Monogrammed" /> Bath Robes - Luxurious Monogrammed </td>

<td class="right_side">2.50 GBP</td>
</tr>

<tr>
<td class="right_side">
<input type="checkbox" name="Bathing " value="Bath Robes" /> Bath Robes </td>

<td class='right_side'> No Charge </td>

<tr>
<td><p></p>
</td>
</tr>
</table></script>
</div>



I am confused a bit further because I am doing this server side with mysql db data. As may be clear, the data in the table, is returned in a server-side loop. how can I output the td's and stuff inside js (if that's how I should be doing it)

any pointers would be most welcome.

bazz

Shannon Blonk
03-30-2009, 01:14 AM
<noscript>
<style type='text/css'>
.stuffThatShouldNotBeSeenIfJavascriptIsDisabled { display:none }
</style>
</noscript>

...

<div class='stuffThatShouldNotBeSeenIfJavascriptIsDisabled'>...</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum