Page 2 of 2

Re: Opening .JS in Firefox

PostPosted: Mon Jul 27, 2009 2:12 pm
by keiferdeanbrown
Okay, so if i use the JavaScript version and link it to the website it will run what i programmed for that website?

Re: Opening .JS in Firefox

PostPosted: Mon Jul 27, 2009 2:36 pm
by thedotmaster
keiferdeanbrown wrote:Okay, so if i use the JavaScript version and link it to the website it will run what i programmed for that website?

Sure will.

Re: Opening .JS in Firefox

PostPosted: Mon Jul 27, 2009 9:44 pm
by keiferdeanbrown
<html>
<head>
<script type='text/javascript' src='test.js'>
function solver(){
var a= document.getElementsByTagName(’INPUT’);
var text = a[0].value;
var prime=0;
var comp=0;
var line=”;
for(i=0;i<text.length;i++){
var c = text.charAt(i);
var comparison =IsNumeric(c);
if(comparison){
var n=Number(c);
if((n!=1)&&(n!=0)){
if(isprime(n)){
prime+=n;
}
if(!isprime(n)){
comp+=n;
}
}
}
else if((line.length<25)&&(comparison==false)){
c=c.charCodeAt(0);
c++;
c=c.toString();
temp=c;
c=String.fromCharCode(temp);
line+=c;
}
}
var sum = 1*prime*comp;
line+=sum;
document.submitform.solution.value=line;
}
function IsNumeric(sText){
var str =”+sText;
var ValidChars = “0123456789?;
var IsNumber=true;
if (ValidChars.indexOf(str.charAt(0)) == -1){
IsNumber = false;
}
return IsNumber;
}
function isprime(n) {
var primer = true;
var ValidChars = “2357?;
var str =n.toString();
if(ValidChars.indexOf(str.charAt(0)) == -1){
primer =false;
}
return primer;
}</script>
</head>
<body>
<!-- www.hackthissite.org/missions/prog/1/ -->
</body>
</html>

how is this wrong?

Re: Opening .JS in Firefox

PostPosted: Tue Jul 28, 2009 12:24 pm
by thedotmaster
Don't know if you know but:
Code: Select all
<!-- this is a HTML comment -->


The way you've done it is not wrong, but the code itself may be. Try looking at your browsers error log (I know Firefox has one, maybe IE doesn't).

Re: Opening .JS in Firefox

PostPosted: Tue Jul 28, 2009 1:40 pm
by keiferdeanbrown
hmmm... there are too many errors to count :?

there is one more option. how easy is a c program to run?

Re: Opening .JS in Firefox

PostPosted: Tue Jul 28, 2009 1:43 pm
by thedotmaster
keiferdeanbrown wrote:hmmm... there are too many errors to count :?

there is one more option. how easy is a c program to run?


Clear the error window then reload the script. Those errors will be from past websites.
You compile C source code into an executable file, I don't think you're ready for C yet. Learning C is hard and takes a lot of patience.

Re: Opening .JS in Firefox

PostPosted: Wed Jul 29, 2009 1:43 am
by keiferdeanbrown
yes i have heard c was harder :?

so i might as well stick with javascript, my next guess is that spacing is important in javascript? and my code has no proper spacing. i have yet to learn the spacing functions for javascript (if they're even important)

ps thank you the dot master for your helping me out! i shall now refer to you as "master" :ugeek: with your training i will be awesome!

Re: Opening .JS in Firefox

PostPosted: Wed Jul 29, 2009 5:14 am
by thedotmaster
No worries, glad to be of assistance.