Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-20-2011, 08:05 PM   PM User | #1
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
help with noscript tags

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
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
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook

Last edited by LJackson; 02-20-2011 at 08:11 PM..
LJackson is offline   Reply With Quote
Old 02-20-2011, 08:24 PM   PM User | #2
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
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

Code:
                <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
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook
LJackson is offline   Reply With Quote
Old 02-20-2011, 08:46 PM   PM User | #3
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
ok got it working

this was the solution
Code:
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
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook
LJackson is offline   Reply With Quote
Old 02-21-2011, 11:32 PM   PM User | #4
quartzy
Regular Coder

 
Join Date: May 2009
Posts: 813
Thanks: 123
Thanked 24 Times in 24 Posts
quartzy is an unknown quantity at this point
Do you use word wrap in your editor? You should turn it on, even notepad has it.
quartzy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:29 AM.


Advertisement
Log in to turn off these ads.