so I am having a page where there is an input field. I want this to work like a CMS system. Let's say that there are options. What I am working on now is one where you can specify how long the summery will be for the content. So I want the input to be saved and sent to the function file where I can use that information in a function. I don't want to be sent to this function file site. Similar to how you can save options in wordpress, but you stay on the same page. I imagine that I perhaps have to use AJAX.
Any help on how I can do this?
If you would like to use some JavaScript here, then localStorage could be of great help to you.
Suppose you have following html form:
<input id = "foo" type = "text">
Write this JavaScript to store the value:
var val = foo.value;
localStorage.setItem(formV,val);
And the following to retireve it:
val = localStorage.getItem(formV);
You can then make an AJAX request to transfer the data to a PHP file:
request = $.ajax({
type: 'POST',
url: 'form.php',
data: { text1: val}});
request.done( function(response) {
alert("cool!");
})
On form.php side:
$val = $_POST['text1'];
echo $val;
You can learn more about localStorage here and many other places.