Click to See Complete Forum and Search --> : [RESOLVED] attach a javascript file
Noodle7
07-27-2006, 12:51 PM
Hi
Is it at all possible to have one page of javascript code which your pages refer to ( like a external stylesheet) ...?
thaKing
07-27-2006, 12:54 PM
yes, it would be something like this:
<script language="JavaScript" type="text/javascript" src="swap.js"></script>
Noodle7
07-27-2006, 01:15 PM
thanks will try that out ...this site rocks I have only been on it a few hours and all my questions have been answered!
Noodle7
07-27-2006, 01:21 PM
<script language="JavaScript" type="text/javascript" src="swap.js"></script>
so this goes where ? I have made a seperate js file and added it in but nothing happens .
thaKing
07-27-2006, 01:23 PM
it goes inside your <head></head> tags...
Noodle7
07-27-2006, 01:33 PM
<script type="text/javascript">
var arr=['100000','100001','1000002']//possible values
function goto(v) {
for(var i=0;i<arr.length;i++){
if(v==arr[i]){
location.href='http://www.africanmob.com/'+v+'.htm';
return;
}
}
alert('This page does not exist!')
}
</script>
I saved the above in a .js file called dealer
The below is what is iin the body of the page
<form>
<span style="cursor:pointer" onclick="goto(document.getElementById('url').value)" class="style31">
<input name="Input" type="text" id="url" size="5">
Go to Dealer </span>
</form>
and your code <script language="JavaScript" type="text/javascript" src="dealer.js"></script> goes in the header ? this ain't working any ideas?
thaKing
07-27-2006, 01:38 PM
your javascript page does not need the <script></script> in it...that only goes in the html page...remove those from your javascript file, save it and in your head tags put
<script language="JavaScript" type="text/javascript" src="dealer.js"></script>
Noodle7
07-27-2006, 01:52 PM
yipeee thanks its working like a dream..., ok last question is there away of clearing the input box once a user has entered a number?