...

View Full Version : help with noscript tags



LJackson
02-20-2011, 09:05 PM
Hi All

im having a bit of a dilemma,

i have a little rating section on my form for users to provide a rating, now i have basic radio buttons display if the user doesnt have javascript enabled but if they do i want to display a fancier rating "image"

here is my code

<fieldset class="rating2">
<legend>Rating</legend>
<div>
<label for="rating">User Rating</label>
<noscript>
1<input type="radio" name="radio" id="rating" value="1" />
2<input type="radio" name="radio" id="rating" value="2" />
3<input type="radio" name="radio" id="rating" value="3" />
4<input type="radio" name="radio" id="rating" value="4" />
5<input type="radio" name="radio" id="rating" value="5" />
</noscript>

<!noscript>
<ul class="rating">
<li id="current" class="current" style="width: 0em;"></li>
<li id="sel1"><a href="javascript:selectElement(1)" class="rate1" title="I hated it">*</a></li>
<li id="sel2"><a href="javascript:selectElement(2)" class="rate2" title="I disliked it">*</a></li>
<li id="sel3"><a href="javascript:selectElement(3)" class="rate3" title="It was OK">*</a></li>
<li id="sel4"><a href="javascript:selectElement(4)" class="rate4" title="I liked it">*</a></li>
<li id="sel5"><a href="javascript:selectElement(5)" class="rate5" title="I loved it">*</a></li>
</ul>
</noscript>
</div>
</fieldset>


the noscript tags work fine if js is enabled but because my other rating "script" is not a js script but uses js to retreive the rating value it is always visable to the user even if js is disabled but it wont work, is it possibe to hide it if js is disabled?

here is my test page
http://www.kernow-connect.com/test.php

where you can see the two different rating sections with js disabled but only want the radio buttons to show if js is disabled :)

any help with this will be great
thanks

LJackson
02-20-2011, 09:24 PM
ok i have changed my code so that the fancier code is now incased in a document.write() function and wrapped in script tags! but now if js is disabled it doesnt display which is expected but if js is enabled it still isnt displaying


<script type="text/javascript">
document.write('
<ul class="rating">
<li id="current" class="current" style="width: 0em;"></li>
<li id="sel1"><a href="javascript:selectElement(1)" class="rate1" title="I hated it">*</a></li>
<li id="sel2"><a href="javascript:selectElement(2)" class="rate2" title="I disliked it">*</a></li>
<li id="sel3"><a href="javascript:selectElement(3)" class="rate3" title="It was OK">*</a></li>
<li id="sel4"><a href="javascript:selectElement(4)" class="rate4" title="I liked it">*</a></li>
<li id="sel5"><a href="javascript:selectElement(5)" class="rate5" title="I loved it">*</a></li>
</ul>');
</script>
<noscript>
1<input type="radio" name="radio" id="rating" value="1" />
2<input type="radio" name="radio" id="rating" value="2" />
3<input type="radio" name="radio" id="rating" value="3" />
4<input type="radio" name="radio" id="rating" value="4" />
5<input type="radio" name="radio" id="rating" value="5" />
</noscript>


have i used the js document.write correctly?
cheers

LJackson
02-20-2011, 09:46 PM
ok got it working :)

this was the solution

document.write("<ul class=\"rating\"><li id=\"current\" class=\"current\" style=\"width: 0em;\"><\/li><li id=\"sel1\"><a href=\"javascript:selectElement(1)\" class=\"rate1\" title=\"I hated it\">*<\/a><\/li><li id=\"sel2\"><a href=\"javascript:selectElement(2)\" class=\"rate2\" title=\"I disliked it\">*<\/a><\/li><li id=\"sel3\"><a href=\"javascript:selectElement(3)\" class=\"rate3\" title=\"It was OK\">*<\/a><\/li><li id=\"sel4\"><a href=\"javascript:selectElement(4)\" class=\"rate4\" title=\"I liked it\">*<\/a><\/li><li id=\"sel5\"><a href=\"javascript:selectElement(5)\" class=\"rate5\" title=\"I loved it\">*<\/a><\/li><\/ul>");</script>


is there a way to make the above more readable??? it breaks when i try and put each element per line
cheers

quartzy
02-22-2011, 12:32 AM
Do you use word wrap in your editor? You should turn it on, even notepad has it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum