confused and dazed Posted March 14, 2012 Share Posted March 14, 2012 (edited) 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 March 14, 2012 by confused and dazed Link to comment Share on other sites More sharing options...
ShadowMage Posted March 14, 2012 Share Posted March 14, 2012 I suspect this line:tournament.action = "sel_tm.php";could be an issue. What is tournament and where is it defined? Link to comment Share on other sites More sharing options...
Ingolme Posted March 15, 2012 Share Posted March 15, 2012 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 More sharing options...
confused and dazed Posted April 12, 2012 Author Share Posted April 12, 2012 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 More sharing options...
justsomeguy Posted April 12, 2012 Share Posted April 12, 2012 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 More sharing options...
thescientist Posted April 13, 2012 Share Posted April 13, 2012 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 More sharing options...
confused and dazed Posted April 14, 2012 Author Share Posted April 14, 2012 (edited) 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 April 14, 2012 by confused and dazed Link to comment Share on other sites More sharing options...
Ingolme Posted April 14, 2012 Share Posted April 14, 2012 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 More sharing options...
dsonesuk Posted April 15, 2012 Share Posted April 15, 2012 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 More sharing options...
confused and dazed Posted April 15, 2012 Author Share Posted April 15, 2012 (edited) 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 April 15, 2012 by confused and dazed Link to comment Share on other sites More sharing options...
confused and dazed Posted April 15, 2012 Author Share Posted April 15, 2012 This fixed the problem - dsonesuk - thank you.It might be unrelated but as soon as I fixed that problem E-mails are no longer being sent to Yahoo/Hotmail/Gmail/etc...Can it be related or do you think it is unrelated? Strange timing if it is unrelated... Link to comment Share on other sites More sharing options...
confused and dazed Posted April 15, 2012 Author Share Posted April 15, 2012 >>>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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now