jamslam
08-06-2003, 05:11 PM
Ok, what I'm trying to do here is disable a submit button, AFTER a form has been submitted, hence preventing the user to submit twice, and possibly duplicate database row's...
My problem isn't that the form isn't being submitted, it's that in PHP the submit button variable isn't being set, BECAUSE it's being disabled first. Is there a workaround for this?
Here is my javascript function, which I have tested in different scenarios, and works fine
function disable_submit() {
obj1 = document.getElementById("content_submit1");
obj1.setAttribute("disabled","disabled");
}
And here is the form
<form method="post" action="" name="form1" onSubmit="disable_submit();">
Template Name: <input type="text" style="font-size: 10pt; font-family: verdana; border: inset 1px;" maxlength="30" name="template_name_form" value="" />
<br /><br />Template ID: <b></b><br />
<textarea rows="22" style="font-size: 10pt; font-family: courier new; border: 1px #000000 solid;" cols="106" name="template_content_form">
</textarea>
<br />
<label for="delete_label"><input type="checkbox" id="delete_label" name="delete_template" /> Delete</label>
<br /><br /><input type="text" name="string" /> <input type="button" value="Find" onClick="find_text(document.form1.string.value); document.form1.find1.focus();" name="find1" /><br /><br />
<input type="submit" name="content_submit" id="content_submit1" value="submit">
</form>
(this is all embedded in a php script BTW)
and here is my PHP code...
if(isset($content_submit)) {
// update database
}
Everything here works, and if i take out the "onSubmit" it works. So i've narrowed it down to the submit variable isn't being set, because the button is being disabled... Everything else is in proper working order... The actual problem is that it doesn't make it through the if clause, thus never updating my database.
Also, if i don't have the isset($content_submit), it sends the script into a loop, so that is needed. I was debating if this should go in the PHP forum or not, but decided it was probably more or less a DHTML thing...
so if anyone understood all my jibber jabber, it would be greatly appreciated if someone could help me find a workaround to this :)
(FYI, i can't provide a link, for this is a script that updates templates for my web site, basically my little admincp, hehe)
My problem isn't that the form isn't being submitted, it's that in PHP the submit button variable isn't being set, BECAUSE it's being disabled first. Is there a workaround for this?
Here is my javascript function, which I have tested in different scenarios, and works fine
function disable_submit() {
obj1 = document.getElementById("content_submit1");
obj1.setAttribute("disabled","disabled");
}
And here is the form
<form method="post" action="" name="form1" onSubmit="disable_submit();">
Template Name: <input type="text" style="font-size: 10pt; font-family: verdana; border: inset 1px;" maxlength="30" name="template_name_form" value="" />
<br /><br />Template ID: <b></b><br />
<textarea rows="22" style="font-size: 10pt; font-family: courier new; border: 1px #000000 solid;" cols="106" name="template_content_form">
</textarea>
<br />
<label for="delete_label"><input type="checkbox" id="delete_label" name="delete_template" /> Delete</label>
<br /><br /><input type="text" name="string" /> <input type="button" value="Find" onClick="find_text(document.form1.string.value); document.form1.find1.focus();" name="find1" /><br /><br />
<input type="submit" name="content_submit" id="content_submit1" value="submit">
</form>
(this is all embedded in a php script BTW)
and here is my PHP code...
if(isset($content_submit)) {
// update database
}
Everything here works, and if i take out the "onSubmit" it works. So i've narrowed it down to the submit variable isn't being set, because the button is being disabled... Everything else is in proper working order... The actual problem is that it doesn't make it through the if clause, thus never updating my database.
Also, if i don't have the isset($content_submit), it sends the script into a loop, so that is needed. I was debating if this should go in the PHP forum or not, but decided it was probably more or less a DHTML thing...
so if anyone understood all my jibber jabber, it would be greatly appreciated if someone could help me find a workaround to this :)
(FYI, i can't provide a link, for this is a script that updates templates for my web site, basically my little admincp, hehe)