Jump to content

Question about "auto saving" PHP, jQuery

Joveice
Go to solution Solved by Hazy125,

You can add "onchange" and similar to form elements to trigger a javascript function which can then send a request to the server adding the information about the change to the database.

 

For example:

<h3>Do you like garlic bread?</h3>
<select onchange="sendToServer()">
	<option value="It's ok">It's ok
    <option value="Of course!">Of course!
    <option value="You'd be a fool to not">You'd be a fool to not
    <option value="Puppies are pretty swell">Puppies are pretty swell
</select>

 

Whenever someone selects a new option it triggers the sendToServer function

Hi.

 

I want to know how those auto saving stuff works, etc some sites I go on and I change my "group" and when I press another thing in the list and refresh the page that thing is now saved in the database and I never hit a submit button on the form (not talking about using cookies to track preferences)

So how is this normaly done? and is it a way to do it in jQuery?

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

You can add "onchange" and similar to form elements to trigger a javascript function which can then send a request to the server adding the information about the change to the database.

 

For example:

<h3>Do you like garlic bread?</h3>
<select onchange="sendToServer()">
	<option value="It's ok">It's ok
    <option value="Of course!">Of course!
    <option value="You'd be a fool to not">You'd be a fool to not
    <option value="Puppies are pretty swell">Puppies are pretty swell
</select>

 

Whenever someone selects a new option it triggers the sendToServer function

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Hazy125 said:

You can add "onchange" and similar to form elements to trigger a javascript function which can then send a request to the server adding the information about the change to the database.

 

For example:


<h3>Do you like garlic bread?</h3>
<select onchange="sendToServer()">
	<option value="It's ok">It's ok
    <option value="Of course!">Of course!
    <option value="You'd be a fool to not">You'd be a fool to not
    <option value="Puppies are pretty swell">Puppies are pretty swell
</select>

 

Whenever someone selects a new option it triggers the sendToServer function

Thank you man, will digg into this now :)

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×