Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,097
    Thanks
    297
    Thanked 12 Times in 12 Posts

    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
    Last edited by LJackson; 02-20-2011 at 08:11 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,097
    Thanks
    297
    Thanked 12 Times in 12 Posts
    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

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,097
    Thanks
    297
    Thanked 12 Times in 12 Posts
    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

  • #4
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts
    Do you use word wrap in your editor? You should turn it on, even notepad has it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •