Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox Javascript Form population Problem 2

Status
Not open for further replies.

Nematoth

Programmer
Mar 29, 2002
48
MY
This code doesn't work in firefox.. anybody know why?

TIA.

---------------------------------------


[tt]
function new_word(form)
{
if(!running)
{
running=1;
failnum=0;
form.lives.value=failnum;
form.tried.value="";
form.word.value="";
index=Math.round(Math.random()*10000)%words.length;
alpha[0]=words[index].charAt(0);
alpha[1]=words[index].charAt(words[index].length-1);
alpha_index=1;
bravo[0]=words[index].charAt(0);
bravo[1]=words[index].charAt(words[index].length-1);
bravo_index=1;
pick();
}
else advise("A word is already in play!");
}
[/tt]

Nematoth
 
This is the other function I use..


[tt]
var alpha=new Array();
var alpha_index=0;

var bravo=new Array();
var bravo_index=0;

var running=0;
var failnum=0;
var advising=0;

function pick()
{
var choice="";
var blank=0;

for (i=0; i<words[index].length; i++)
{
t=0;
for(j=0; j<=alpha_index; j++)
if(words[index].charAt(i)==alpha[j] || words[index].charAt(i)==alpha[j].toLowerCase()) t=1;

if (t) choice+=words[index].charAt(i)+" ";
else
{
choice+="_ ";
blank=1;
}
}

document.f.word.value=choice;

if (!blank)
{
document.f.tried.value=" === You Win! ===";
document.f.score.value++;
running=0;
}
}

[/tt]

Nematoth
 
How about posting the code that calls those functions?

Where do you call "new_word"?

What parameters are you passing?

What does your HTML look like?

Do you have a form called "f"?

Give us something to go on!

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
What kind of erros are listed in Firefox -> Tools -> JavaScript Console ?
 
Drop some alerts into your functions (just after the function definition) so that they alert as soon as the function is called. Add another at the very end of the function (so the last thing that the function does is alert you).

Using those 2 simple suggestions will help you narrow down where the problem is occuring. The code itself looks fine, so it's probably going to be something like using a reserved word or something (that IE isn't bothered by).

Those alerts will help identify the function to begin with. Once you know the function... add in alerts in that function until you find the point the code is breaking.

Let us know how you go!
Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
ok guys.. thanks for the hints.. it was actually someone elses code that I was assigned to fix and it turns out in the HTML, the form tag didn't have an id attribute and the actual form wasn't even closed!! Thats all it was..

Nematoth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top