Is there any way to convert this to a submit button? here is my code:
<a class="button small red" href="#" id="submitUpload"><span>Submit</span></a>
I followed this tutorial: http://acrisdesign.com/2011/06/create-a-multi-color-and-size-css3-butt ons/#
So if I had this form: <form enctype="multipart/form-data" name="fileUpload" id="fileUpload" method="post"> <a class="button small red" href="#" id="fileUpload" onclick="document.forms['submitUpload'].submit();"><span>Submit</span ></a >...
when I do the "document.forms...", will it execute this?: if ($_POST['fileUpload']) {
I seem to have issues actually submitting it.
And yes, that <noscript> is a good idea. Will probably use that, as I have before. All I do is set the visibility to none for the button, then if javascript is enabled, toggle the visibility.
no - i am just concerned with getting the form submitted. post fileUpload checks if the form was submitted. I tried running the code above, but it didn't seem to do anything. with the submit button, you would set the name to fileUpload to run the php validation. I am not sure here how to do this though with a link. I understand the code, and it should work. I must me doing something wrong.
Sorry for my previous goofy answer. The data was staring me in the face and I missed it!
Try making your code look like this -
onclick="document.forms['fileUpload'].submit();"
You need the name of the form being submitted in that location, not the name of a field.
so I have if ($_POST['fileUpload']) {...
and
<form enctype="multipart/form-data" name="fileUpload" id="fileUpload" method="post">
and
<a class="button small red" href="#" onclick="document.forms['fileUpload'].submit();"><span>Submit</span>< /a >
but it does not do anything. Is there anything else that I could be missing?
Now you've confused me. The PHP would have to be conditional on some element that is present in the $_POST array. The form name is not. So, if(isset($_POST['form_field_name']) && $_POST['form_field_name'] == 'some_value') { ?>
The javascript would submit based on the form's name attribute value, i.e., document.forms['fileUpload'].submit();
I would use this -
<?php if (array_key_exists('some_field_name', $_POST) {
//processing code follows
...
}
?>
So far, we don't know the name of any of your form's fields - I usually use the name of the submit button, but you could also have a hidden or visible field with a name that you use here.
North America
Europe, Middle East and Africa
Asia Pacific