-jQuery Form plugin- Working with multiple targets / data - php

I'm working with the jQuery Form plugin and was not able to find a solution for the following issue in their API:
With .ajaxForm i want to retrieve 3 or more fields out of a database. The content of each field should be written in 3 matching elements on index.php. I can get and write a single field by using
target: '#element1'
in my javascript file and by using
echo $content ;
in the matching php-script.
So how can i return more data in a single script? My thought was to return an array, but i have no idea how i target the different elements.

Well, once more, i figured it out.
So if there anytime someone will be who is trying to:
Fill a HTML Form with Database content without refreshing the Page
Here is how it can be done:
You'll need the following:
The html with the form you want to fill
The PHP script which gets your data from the database
The jQuery script which is handling both
I hope i did not miss something, got quite a headache after this. Feel free to ask.

Related

Move form entries between Wordpress Gravity Forms

I have a tournament with multiple divisions and multiple forms for which I use gravity forms.
There are times when someone requests to be changed to a different division. However, I am unable to move the competitor from one division to another in gravity forms, as the divisions are each using a different form ID (and they have still not developed a method for helping with this).
How would I go about moving a SINGLE ENTRY from one gravity form to another forms entry list please.
We have many teams at the tournament, so mass export and import is not what i am looking to achieve. Its about being able to move a single entry from one list of entries in one form to another forms list of entries?
ANY help would be greatly appreciated. Even a simple "use this method" in general terms will help me greatly. Would I use some form of JQuery fiddle, a php script, an sql script or what please as Import Entries is not available currently in GF
Regards
You can not do that, but instead maybe you shold design your form to include all types of submissions logic. I mean you can put a drop-down field at the beginning of your form. Then you can use https://gravityview.co/ to edit your single entry field.
I have a workaround for this which i am using in one of my current projects for http://projects.dzign-r.com.au and that is,
1) export both of the the forms (i.e the one from which you need the field to move and the other to which you need this field to be moved to) and it exports these as json files
2) search for the field ID that you need to be moved to another form, cut its json code from the json file and paste it in the other form's json file where you need it to be moved to
3) then import the form back. and test it to make sure it works as you want it, (as a caution you may change the field ID after you paste it in new form to be something which is not used in this form already).
4) once u see everything is fine u may just delete the old form?

How do I create a form without refreshing the page at the same time the data goes into a mysql data base?

Ok, I know there have been a few questions posted on this but a lot of the information are dotted around and not necessarily connected in one form that I need for my site.
Basically I want to create the style/functionality of the twitter form on their home page.
Where inside the input fields are the labels, and when you click on the input the fields the labels don NOT disappear but fade into a different colour. Its only when you type, is when it disappears.
If they don't type and press submit I want the verification signs come up ( I know how to do this but it seems to be conflicting when I put the jQuery code in)
When all fields are inputted I would like the form to fade and represent a thank you message whilst
the data gets placed into a mysql ( specifically a MAMP/PHP My Admin) database.
Very similar to this form on hbuddy.com
Would massively appreciate if this was responded in a step by step format, simply because i am at the beginning stages of learning pretty complex programming language.
Thanks!
you can try jquery ajax for form submission..
These links will help you for getting started..
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
http://www.9lessons.info/2009/04/submit-form-jquery-and-ajax.html
http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/

taking form input / processing / returning information on another page

I have asked this question in a similar manner here before and got a mixed response.
Having done some more homework I feel the need to ask again as I am taking a far more logical view toward it.
I have a search box, I want to take the the query from the search submission, process it and return the result to an Iframe in another page.
Very much like a php email form, but with a twist.
Ideal Scenerio:
search box query > process the query( the query is sent to external server in a string and processed, then returned as a html page > page displayed in an Iframe on another page.
I would like any suggestions or example code would be good.
Only some suggestions as I've not ready code to show you here:
this seems to me the ideal situation to use AJAX.
BUT I'd create and use a box (with div tag) rather than using an iframe.
You should bind your searchbox submission with a function that make the ajax call to a script that process the search parameters and provide you with results.
Once results are ready, your function callback will make them appear in your box (modifying the inner html contents of the box).
I think MAYBE you could get same result with an Iframe but, personally, I don't like using frames.
Hope to have helped you.
Here for you a little ajax tutorial showing just something like the thing you need

Creating product relations using PHP/Ajax/jQuery

I'm working on a self-made e-shop CMS and in the backend and I need to be able to create relations between products. When adding a new product I want to be able to open a popup window in which I can select the related products and then, when I close the window, I need the selected items to be sent back to a field on my page (ie comma delimited string with the selected values). It doesnt HAVE to be a popup window, I'll be glad to use any other method as well, as long as it does the above.
Which ways can I do this? I know Ajax/jQuery will probably do the trick but I don't have much experience with them.
There are a lot of ways to achieve that. One of these in the following scenario:
First: You have a PHP script that connects to the database and get your data.
$query = "your query";
$results = mysql_query($query);
$yourdata = array();
while ($row = mysql_fetch_array($results,MYSQL_ASSOC))
{
/* format the data in JSON format*/
}
echo json_encode(array("yourdata" => $yourdata));
Second: Using jQuery or JavaScript to make an ajax call to the script and then read the returned data from the PHP script and output it in HTML elements.
Or you you can format the data in your PHP script and use JavaScript to parse it and display it.
I can't show you a complete example here for all that but if you search around you will find a lot of examples.
I also highly recommend, if you want to get started with all of this, Head First jQuery, a fantastic book that gets you started with jQuery.
There are great chapters such as chapters 8 and 9 where you will find how you can use jQuery and ajax to get the data and pass it back.
You will find the example code in this link. Download the sample code for chapter 8 and 9 and try it.
For the popup window part there are a lot of plugins and there are also jQuery UI try this: Modal form.
I hope that will be helpful.

AJAX - how to make autocomplete/autosuggestion and show results outside form, in table

im trying to make a simple page with search engine. i read, that if i want to implement autocomplete/autosuggest with form, i have to use ajax. thats ok for me. there are a lot solutions on the intenret, but unfortunetly all of them is the same script :/ and thats fine for me :) but i want to go further. i want to show autosuggest results in table for example below search form. the data is stored in a simple array (eventualy, source mysql) i know that kind of script isnt easy to write, so i ask you to give me a hint or something. trivial solution is use php, but this needs submit button.
help, im stuck :)
You have to follow steps given below
1] Apply onkeyup on the textfield and called ajax request
2] findings = select * from artists where name like "params[]%"
where, params[] is the content of the textfield
findings is ur variable which should pass to the view as response.
3] Called a partial (view) in which you create a table depending on the response and replace a div on each ajax request.

Categories