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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    linking js to php?

    Hi all,

    I'm trying to link a java script file to a html file but it's not working.
    Any ideas?

    HTML:
    Code:
    <head><script type="text/javascript" src="newjavascript.js"></script></head>
    <body>  <div id="myRadioGroup">
    
    2 Cars<input type="radio" name="cars" checked="checked" value="twoCarDiv"  />
    
    3 Cars<input type="radio" name="cars" value="threeCarDiv" />
    
    <div id="twoCarDiv" class="desc">
    2 Cars Selected
    </div>
    <div id="threeCarDiv" class="desc">
    3 Cars
    </div>
    </div>​
    </div></body>
    JS:
    Code:
    $(document).ready(function(){ 
        $("input[name='cars']").click(function() {
           
            var test = $(this).val();
            $(".desc").hide();
            $("#"+test).show();
        }); 
    });​

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,171
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    And where, pray tell, is there any PHP involved, in any way???

    Anyway... You are using jQuery code, not basic JavaScript, so you have to *ALSO* link in a jQuery library.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    php1306 (02-26-2012)

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    the coding is mostly php apart from this one page, i should have said html instead. What's a JQuery library?


  •  

    Tags for this Thread

    Posting Permissions

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