The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. July 22, 2019, 09:54:28 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Form will not submit under any conditions....  (Read 2452 times)
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« on: March 09, 2012, 05:31:45 PM »

Can someone help me see why this javascript will not submit my form. I tried all the ones remarked out.  Its important to submit without using the form name as many of then will not have a name but they will all be form number
  • since there will never be more than one form on the page... but there will be no form name like "myform" as shown. I only named it to see if that would make it submit but that did not work either...The variables are changing when I do that but not click the button..
Code:
<html>
<header>
<script>

function dowork() {
alert("Change user and Pw.");
document.forms[0].username.value="Truck Man";
document.forms[0].password.value="jockotogototown";


// alert(document.forms.length); // Shows a form length of 1
// document.forms[0].submit(); // fails
// document.myform.submit(); // fails
//document.forms["myform"].submit(); //fails
// for(var i = 0; i < document.forms.length; i++) { //fails
//     document.forms[i].submit();
// }

}  

</script>


<header>

<body>

<form name=myform action=doit1.htm>

UserName: <input type=text name=username value="Manchester Milo"><br><br>
Password: <input type=text name=password value="thunderball"><br><br>
<input type=submit name=submit value="Submit"><br><br>
</form>
<br><br>
<a href="#" onclick="dowork();">Click here</a><br><br>


<a href="#" onclick="document.forms[0].submit()">Submit form</a>

</body>
</html>

Logged
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #1 on: March 09, 2012, 05:34:03 PM »

Please note that this must be able to submit on FF only. I have not checked it on IE but that matters not anyway. It must be used on FF.
« Last Edit: March 09, 2012, 05:54:00 PM by tommytx » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: March 10, 2012, 01:51:32 PM »

I'm traveling and can't really look at it till tomorrow, but will then man.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #3 on: March 10, 2012, 03:21:50 PM »

Thanks..
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #4 on: March 10, 2012, 09:43:16 PM »

how do you know it's not submitting?
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #5 on: March 10, 2012, 09:47:40 PM »

When I click the submit button via mouse it goes to the action site... when I issue any of the remarked out attempts it does nothing.. just to make sure the javascript is being called I added an alert so that it gives an alert each time the sub is called..
Also it does fill in the user and password portion but just never makes it to the submit part... it looks like my commands should work... maybe I will try it on another puter....
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: March 12, 2012, 11:07:11 AM »

Is there a specific reason you want to do that all in JS and not just with a type="submit" button? You can still trigger on that and do any JS work you want to (and even deny the submit) rather than trying to submit it manually...?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!