Jump to content

FIREFOX MOZILLA does not like my code. Please help.


confused and dazed

Recommended Posts

Hello Internet,I have completed my first project and some users are having an issue with submitted forms. They click the submit button and nothing happens - I don't get the information in my database.It appears FireFox MOZILLA is the problem – My internet explorer browser users are not having the issue. Here is some of my code In the main file mainfile.php at the bottom I have this code: <input type="button" class="cntbtn" name="Submit Bracket" value="Submit Bracket" onclick="checknsubmit();"> After clicking the submit button it goes to a .js file where the function below is controlling the outcome: function checknsubmit() {tournament.action = "sel_tm.php";var // I declare a ton of variablevarvarIF ( ) // I have a ton of IF statementsIF ( )IF ( )}document.getElementById('tournament').submit()} // and if all the conditions are met I use this statement to send the information to the php file sel_tm.php The php file accesses the database and performs a bunch of tasks and then e-mails the user some information.I am not seeing the new window come up that states "your submission has been received" and there is no information that has been sent to the database…Is this something that I can fix easily?

Edited by confused and dazed
Link to comment
Share on other sites

Internet Explorer has a "feature" that assigns elements to global variables of the same name as their ID. You should never rely on this feature. I also recommend an onsubmit handler for the <form> rather than an onclick handler on the button.

Link to comment
Share on other sites

  • 4 weeks later...

I found some information suggesting that Firefox wont process document.getElementByIdIs this true? I also found this code on the internet that suggests all browsers will work with this code when using getelementbyid for assigning variables... I wanted to run it by you guys... var z=function(elementid){return document.getElementById(elementid)};

Link to comment
Share on other sites

I found some information suggesting that Firefox wont process document.getElementById Is this true?
No, all browsers follow the DOM spec for that function as far as I'm aware.
I also found this code on the internet that suggests all browsers will work with this code when using getelementbyid for assigning variables... I wanted to run it by you guys... var z=function(elementid){return document.getElementById(elementid)};
That's just a shortcut to another function, you're defining the function z to be an alias for document.getElementById. It doesn't add any additional features or any additional support.
Link to comment
Share on other sites

what about errors? If the tournament object/element/reference is not defined, you can't assign properties to it.

tournament.action = 'sel_tm.php';

I would advise debugging your code by using the page with the error console open. document.getElementById is most definitely supported in FF, it is a standards compliant browser.

Link to comment
Share on other sites

The error code is saying the following:tournament is not defined and it points to the following code in my .js file:tournament.action = "sel_tm.php"; I have defined it... Here is the line in the .php file that defines form "tournament"<form name="tournament" id="tournament" method="post" target="_blank">

Edited by confused and dazed
Link to comment
Share on other sites

That's not how you define a variable. This is how you define a variable:

var tournament = document.getElementById("tournament");

Variables are defined only with Javascript and never with HTML.

Link to comment
Share on other sites

IE will read the id ref of form with tournament.action = 'sel_tm.php'; to set action value, BUT! for FireFox and maybe other browsers you will have to use document.tournament.action = 'sel_tm.php'; or even document.forms.tournament.action = 'sel_tm.php'; which will work for IE as well, this method is the old dot notation method, the method used nowadays is to use document.getElementById("tournament"); as already mentioned.

Link to comment
Share on other sites

Ingolme, I think dsonesuk address the question I had. I was not trying to define the variable tournament I was trying to submit the form tournament. Maybe I should have clarified my latest question because previously I was asking about code I was thinking about pirating off the net. That code was trying to establish variables which at the time I thought maybe was the issue. I will try dsonesuk's code and see if it fixes the problems. Thanks to all for taking the time to respond to my questions!

Edited by confused and dazed
Link to comment
Share on other sites

>>>No worries - the e-mails were sent out just a little slow for some reason this morning. BTW... To the following folks - ShadowMageIngolmejustsomeguythescientistdsonesuk you have been instrumental in getting my site off the ground before the NCAA tournament started. Please take a look and see what you helped me create!!! Go ahead and submit a bracket. I'm sure you can poke some holes in it so please let me know where I can improve it - I would love that.I could not have done it without you guys!!! I mean that! www.cp2000madness.com

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...