i made a plugin to upload a image file which is already exist in database.image of plugin given below.
This modal have one <form> tag.
Now i wants to implement this code to my form.so Form Have Already one form So how can i manage Both Form.
if user upload file than above form will skip and this form is submitted and above data will be lost.
My Form is like this
remember you should provide your work
$("#html_form_id").submit(function() {
$( "#modelForm_id" ).submit();
return false;
});
Description is ambiguous not clear if you want to submit first form, second form or both.
Related
I currently have a form which users can traditionally click on a submit button to save. The form action goes to a page called formProcess.php, which contains a meta-redirect that will save everything then redirect the user back to the form.
I have been requested to add a new feature to a hyperlink on the form page which will automatically save the form before following the hyperlink to a different page. I've currently got some simple jQuery connected to the hyperlink which submits the form like so:
$('#hyperlink').click(function() {
$(this).closest("#save_form").submit();
});
This works and submits the form, but of course formProcess.php has a meta-redirect in it which will take the user back to the form page which I don't want.
I figure if I could pass some extra parameter in the Javascript form submission, like submit('redirect=link'); then I could add something like this to formProcess.php:
if ($_POST['redirect'] == 'link') {
// Redirect 1
} else {
// Redirect 2
}
Is this possible? I can't seem to find any information on being able to pass any extra parameters using submit(); If not, what would you suggest is the best way to tackle my problem?
You can append a temporary field to your form.
$('#hyperlink').click(function() {
$(this).closest("#save_form").append('<input type="hidden" name="redirect" value="link" />');
$(this).closest("#save_form").submit();
});
In your form you can use hidden input type.
Ex.
<input type="hidden" name="redirect" value="link"/>
so when form is submit your hidden field value also to be submit with other parameter.
in your php you can simply do as below:
if ($_POST['redirect'] == "link") {
// Redirect 1
} else {
// Redirect 2
}
You can either use ajax to submit your form and upon success then redirect to the url you want.Without using ajax you could add a hidden field in your form and change it's value.Then server side you ll be able to check the value of you hidden field and act accordingly.
I've a jQuery code which show/hide some disabled fields, based on an user select option:
$('.fieldcontent').not('.info').hide();
$('#selector_cs').change(function() {
$('.fieldcontent').customFadeOut(100);
$('.' + $(this).val()).customFadeIn(900);
$('input').prop('disabled',false);
$('textarea').prop('disabled',false);
$('select').prop('disabled',false);
});
});
The big headache is: if one or more fields are fading in, these fields doesn't pass my php validation, nor submitting the form.
If javascript is disabled on all browsers, the form works perfectly.
PHP validation is
if(!isset($_POST['products'])) {
$products[2] = clean_var($_POST['products']);
}
else {
$error = 1;
$products[3] = 'color:#FF0000;';
}
for all fields
Is there any php /jquery solution (no ajax please, 'cause i won't make the whole form again, and don't know anything about ajax)?
Thanks in advance for help
EDIT: Just detected another error: If the jquery script fadein another section of the form, PHP doesn't validate it anymore. Why? Never had problems like this with php-jquery.
If you leave them enabled, but change the property type to hidden then PHP should see the fields when you submit them.
Update
How about the following scenario:
5 fields shown
start-hiding two fields (A+B)
'add' two type=hidden fields with the same name as A+B and copy their current value from A+B to `A+`B
PHP should see these two hidden fields instead of the fields that are currently fading out.
If the user did not submit while fading out, then when the fields have faded out remove the `A+`B fields and set the property of the two faded fields to hidden
Inverse this for showing them fields again.
Do take note that this is not a problem caused by PHP but caused by how/when a browser interprets a form field to be a valid form field to be send when submitting the form
I'm submitting a form in JavaScript inside the onclick event of an image, the problem is how to know in PHP that i'm coming from the image submission?
if(isset(??))
{
//submission code
}
Note: the form action is $PHP_MYSELF
You could perhaps place a hidden field in your form and test on that.
Since you're submitting a form, why not check for a form submit in PHP using:
if(isset($_POST))
{
//do code
}
I was creating a form with validation
here is the js file is : http://pastebin.com/Ahy4dbsS
php file : http://pastebin.com/5B1hMK49
the problem is when I submit the form without clicking on any text boxes,
no validation happens, so i changed the js file so that the first text box will be focused on page load.
but when that text box is validated (ie. click outside of the form) and form can be submitted without validation. how can i validate all the text boxes on page load?
Better use a variable ex: var flag=0; and for every condition increment the flag as flag=flag+1; do this in all conditions finally make a condition:
if(flag>0){return false}else{return true}
I know that it probably isn't possible to submit a form from one button to 2 various locations so I was wondering if someone knew of a solution.
When I click submit on a form I have the following form tag:
<FORM ACTION="http:site.com/servlets/RequestServlet" method="post">
But I want the form to have 2 action parameters. This way as soon as a user fills this form out, submits the form, the form is submitted to a SERVER AND a PHP script that will pull out the parameters submitted by the the form and email the user details about their form submission such as request ID etc.
Over here the Servlet is submitted to so that a record can be made in the network but an email is required to be sent to a user after form submission in-case they need to reference later on to a rep about their request id for further assistance.
How can I achieve the submission to a PHP script in addition to the submission to the Servlet that's already occurring?
NOTE: I cannot modify the Servlet in any way as it does not belong to me. All I want to do as add the email function for a user to later reference their ticket id.
Set a javascript onclick parameter for the submit button. So it will post to the action you set, but also run a function such as:
function secondSubmit() {
url = "myphpscript.php";
data = { someData: "data", someOtherData: 2 };
$.post(url, data, function(returnedData) {
// can do something on return if you'd like here
});
}
someData and someOtherData will show up in PHP as $_POST["someData"] and $_POST["someOtherData"]. So basically, you will have the form submit to the first URL via the HTML form, and have the second form submitted via jQuery with this function. Alternatively, you can do both submissions in this function and have the form have no action.
For more info, see here: http://api.jquery.com/jQuery.post/