tags:

views:

225

answers:

2

I want to show values of two radio buttons in the span tag when they are clicked, but this is not working :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Untitled Document</title>
        <script src="jquery.js" type="text/javascript">
        </script>
    </head>
    <body>
        <p>
            your amount is : <span id="displayPrice"></span>
        </p>
        <input type="radio" value="159" name="price" onclick="$('displayPrice').html(this.value)">
        <br>
        <input type="radio" value="259" name="price" onclick="$('displayPrice').html(this.value)">
    </body>
</html>
+11  A: 

$('displayPrice') isn't a valid selector. You're wanting $('#displayPrice').

After the fact, but for what it's worth it is normally a good idea to separate out your javascript handling code and placing it into a ready event e.g:-

$(document).ready(function() {

    $("input[name='price']").click(function() {
        $('#displayPrice').html($(this).val());
    });
});
Gavin Gilmour
Thanks for correcting me :)
Datis
A: 

What did not working?