|
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?
|
|
|
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
|
|
|
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
|
|
|
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>
|
|
|
|
|
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>
|
|
|
|
|
Sorry for the incomplete post! I fat-fingered and accidentally submitted while I was typing my reply.
|
|
|
|
|
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
|
|
|
Glad we could help, Inca. Let us know if you need anything else.
|
|
|
|
|
|
|