codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Disabling Button Problem  Archive Import (IncaWarrior) at 23:48 on Wednesday, July 30, 2003
 

I have a disable script that i use, which works, except the data is never submitted, the source looks like this (including relevant parts):

function postit() {

window.document.form1.fake.value=window.document.form2.text.value;
window.document.form2.submit();
window.document.form1.normal.disabled="true";
window.document.form2.action="[form_action]";
}




<form name="form1" method=post action="[form_action]" onSubmit=`postit()`>

<table border=0 cellpadding=3 cellspacing=0>
<tr><td align=left valign=top>Text:</td>
<td align=left>
<textarea rows=6 cols=35 name="fake" wrap=virtual></textarea>
</td></tr>
<tr><td></td><td align=left valign=top>
<input type=submit name="normal" value="Submit">
</td></tr></table>
</form>

<form name="form2" method=post action="[form_action]">
<input type="hidden" name="text" Value=""></form>

Can anyone see any flaws or have any idea why it won`t work?

  Re: Disabling Button Problem  Archive Import (David) at 05:38 on Thursday, July 31, 2003
 

nothing will happen in the function after the line

window.document.form2.submit();

if will submit the form and that`s that. The remaining two lines would not be read.

I`m not quite sure what you`re trying to do here. Is is just to disable the submit button to prevent double clicking? In which case, the function just needs to be called onsubmit, and contain the code to disable the button, followed by form.submit()

Hope that helps.
David

  Re: Disabling Button Problem  Archive Import (IncaWarrior) at 13:11 on Thursday, July 31, 2003
 

no, it doesn`t since your wrong, but thanks for trying

the function does disable the button but it doesn`t submit the information. i`d heard that once the button is disabled the form is basically blank, so i`m trying to copy it to another form

  Re: Disabling Button Problem  Troy Wolf at 00:10 on Friday, August 01, 2003
 

Inca, I could reading in tone where none was intended, but I hope you weren`t getting rude with David--he`s just trying to help. I have to agree that I`m not sure what you are trying to do there. You are copying one form to another just so you can submit the data? What is your goal? If you want to have a form that can only be submitted once (prevent users from hitting submit a second time), this can be done without copying form data to a second form. Here is the strategy I use:

<script language=JavaScript1.2>
var formSubmitted = false;
function DoMethod(fMethod) {

if(!formSubmitted) {

}
</script>

Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Disabling Button Problem  Troy Wolf at 00:27 on Friday, August 01, 2003
 

IncaWarrior, I may be reading tone where none was intended, but I hope you weren`t getting rude with David. He`s trying to help. I have to agree with him, I`m confused by what you are doing. What is your goal? Having to copy a form to a second form just to submit the values is odd. There are better ways to keep users from clicking the submit button more than once. Here is a strategy I have used successfully in numerous projects. Some things to note: I do not use a type=submit button. Instead, I use a type=button, then script it to call my submit function. My submit function simply sets a variable called formSubmitted to TRUE. This way, I know when the form has been submitted, and can block second and third attempts. Also note in the <form> tag there is `onsubmit="return false;"` This keeps the default submit from occuring. Test this by adding a normal type=submit button to the form, then click it--the form will not submit. The LoadTrigger() function is just a standard I use to get my form object into an easier to use variable. Also, you can script anything else you`d like to occur on page load in this function--such as placing focus() on your first form field, etc. I hope this solves your problem. If not, I apologize for not understanding your goal.

<script language=javascript1.2>
var myForm;
var formSubmitted = false;
function DoMethod() {
if(!formSubmitted) {
formSubmitted = true;
myForm.submit();
}
}
function LoadTrigger() {
myForm = document.forms[0];
}
window.onload = LoadTrigger;
</script>

<form method=post onsubmit="return false;" action="/forum/SomeOtherPage.html">
Field 1: <input type=text name=field1><br>
Field 2: <input type=text name=field2><br>
<input type=button value="Submit" onclick="DoMethod()">
</form>
Troy Wolf: site expert
SnippetEdit Website Editor


  Sorry for the incomplete post  Troy Wolf at 00:29 on Friday, August 01, 2003
 

Sorry for the incomplete post! I fat-fingered and accidentally submitted while I was typing my reply.
Troy Wolf: site expert
SnippetEdit Website Editor


   Archive Import (IncaWarrior) at 01:44 on Friday, August 01, 2003
 

your script should work, i`m trying to find what is needed from the form.

if you sensed any negative tone then it was just misinterpreted. I am grateful for any help i can get

  Re: Disabling the submit button on forms  Troy Wolf at 18:32 on Monday, August 04, 2003
 

Glad we could help, Inca. Let us know if you need anything else.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Disabling Button Problem  Elain at 08:36 on Thursday, January 13, 2011
 

I' not good at this kind of question, and i always think it is very difficult for me to solve it!
_____________________________________________
decompiler for mac|tree menu|flash banner








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Doubles .toString Error: double cannot be dereferenced.
•  Re: What VBA code can I use to extract the IP Address
•  Re: difference between activex dll and an exe
•  Re: New user, trying to figure out how `find` works....
•  Re: adding a querystring parameter in a button click event
•  Re: onclick thumbnail images in gridview or datalist
•  Re: MDI form open size and location
•  Re: where can i download javax.speech package
•  Re: need help with main()


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011