...

View Full Version : linking js to php?



php1306
02-24-2012, 04:55 PM
Hi all,

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

HTML:


<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:


$(document).ready(function(){
$("input[name='cars']").click(function() {

var test = $(this).val();
$(".desc").hide();
$("#"+test).show();
});
});​

Old Pedant
02-24-2012, 09:29 PM
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.

php1306
02-26-2012, 01:30 PM
the coding is mostly php apart from this one page, i should have said html instead. What's a JQuery library?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum