In oscommerce I want to refresh the product div called 'left-div' with form field checked results on autosubmit- rather than whole page:-
I use oscommerce 2.3.4:-
Step wise I have below files-
I have pulled a form on index.php in a div called 'right-div',
which is called from a box module bm_form.php using below code-
if (class_exists(bm_form)) {
$boxdata = new bm_form;
echo $boxdata->getData();
}
Now this form has below code for action on bm_form.php:-
<form name="form_srch" id="form_srch" action="'.tep_href_link(FILENAME_DEFAULT).'" method="get" >.....</form>
The form is processed at this folder
ext/form/form.php
ext/form/form.js
ext/form/form.css
The above form process is called in my index.php using below code:-
at very top
require('includes/application_top.php');
require('ext/form/form.php');
The issue is I when I fill the form it triggers the entire page to refresh whereas I need to refresh only the div with form result.
My form.js uses below code for submit
$("#form_srch").submit(); // submit form
I tried using the idea given here for ajax refresh of Div-
Refreshing ajax div with form data
Editing this code in ext/form/form.js:-
$("#form_srch").submit(
function(e){
e.preventDefault();
$.get('ext/form/form.php', $(this).serialize(), function(data){
$('#left-div').html(data);
}
);
return false;
}); // submit form
And removed the action part from the form leaving action=""
But still it does not work at all the form stops working altogether,
Please can someone help me get this working......
Related
I have WSForm Pro form management plugin installed on my Wordpress site. The plugin utilizes AJAX as the only method to post a form's data so that only the form's area is updated on submit, not the whole page. On submit I need to show-up the form's data on the same page.
What I have done. Through adding a function to functions.php of my theme I'm able to get the form's data as a session variable:
// Add action to process WS Form form data
add_action('wsf_action_tag', 'wsf_action_function', 10, 2);
// My function for action
function wsf_action_function($form, $submit) {
// Get submit value (Change '123' to your field ID)
$submit_value = wsf_submit_get_value($submit, 'field_18');
session_start();
$_SESSION['form'] = $submit_value;
// Do something with $submit_value here
// ...
}
I also added the following php-code to the page with the form to show-up the session variable above:
<?php
session_start();
$form = $_SESSION['form'];
var_dump($form);
?>
The problem. When I submit the form, nothing changes except built-in success message (as supposed with AJAX), though on page reload the submitted data is shown-up successfully. If I could have my own AJAX script, I would want to modify it slightly to reload the whole page. But since I use a third-party plugin, it's makes the task too complicated.
The question is how would I change any part of my code to show-up the form's data on submit on the same page?
Found a workaround in WSForm functionality! From "Edit Form" choose "Actions", "Add", "Redirect" and point the page's redirect to itself.
Click to to see the screenshot
First page has form using method POST with action to the offer page.
<form id="value-form" method="POST" action="/offer/">
When user submits form on the first page, I want on the offer page class="add-info" to be added to the <form so then it fires up the jQuery script
<form id="formOffer" class="add-info">
Jquery
if (formOffer.hasClass('add-info')) {
launchrocket();
}
I can't figure out class tag can be added via PHP to the new form on the process page.
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.
is there way to submit part of a form without refreshing the whole page? Basically, I want to add a search box with a button in the view, when I click this button it runs a function / action in the controller. My apology if this has been asked before but I've searched for couple of hours and I couldn't understand the ones I came across.
This page will help you learn about how CakePHP handles AJAX:
http://book.cakephp.org/3.0/en/controllers/components/request-handling.html
Now, be aware the default behavior of a form is submit itself to a page or to the same page (reloads). If you want to prevent the form from submitting (reload the page) have something like this:
<form onsubmit = myFunc() >
..
function myFunc(){
//Send the ajax request. You can use JQuery
//Handle response
return false; //This will prevent the page reload...
}
I have been on this site all day and can't seem to find what I need - no duplicate post intended.
I have a form containing a link which calls a modal popup containing a different form.
###### PARENT PAGE #############
<form...>
...
link
...
</form>
**** MODAL POPUP ****
<form...>
...
<input type="submit" />
</form>
**** END MODAL POPUP ****
### END PARENT PAGE #############
When I submit the form in the modal popup, the parent page is refreshed to show the updated info in the corresponding section of the page; except that the first form is not submitted and when the page refreshes to update the necessary section, the contents of the first form is lost.
I have tried using ajax to refresh only the necessary section of the page but that doesn't work as the sections that need refreshing use php variables with contents from mysql.
The system does what it needs to do and I don't mind the refresh. But I need a way to keep the user data entered into the first form.
Is it possible to submit the first form at the same time as the second to the same php page or any other way of preserving the user data in the first form on page reload without submitting it.
You cannot do this with pure php. You'll need javascript and write it in a way that when you hit submit on the modal it 'puts' the information back into the parent form.
One way is to make the modal form submit button not an actual submit button.
You might even be able to get away with taking the filled out section dom elements in the modal injected back into the parent form. Some jquery plugins already do this. For example colorbox
Here is a working example using only ONE <form> tag and jquery colorbox. http://jsbin.com/olalam/1/edit
I am not a php developer, so I'll suggest an alternative approach.
Before you refresh the page, you can serialize the form and store the data locally (e.g. in a cookie) then restore the data back into the form. Granted, that will require a bit more JS code, but should get you what you want.
UPDATE: Since you mentioned that you might need a little assistance on the JS front, here is some guidance:
Grab the jquery.cookie plugin here.
Grab the jquery.deserialize plugin here.
Use the following code as a starting point.
.
// the name of the cookie
var cookieName = 'myCookieName';
function beforeSubmit() {
// serialize the form into a variable
var serializedForm = $('#id-of-form').serialize();
// store the serialized form
$.cookie(cookieName, serializedForm, { path: '/' });
}
function afterRefresh() {
// read the cookie
var serializedForm = $.cookie(cookieName);
// de-serialize the form
$('#id-of-form').deserialize(serializedForm, true);
}
HTH