JaimeJegonia
asked on
JavaScript: preserve fields after refresh
below is a javascript function which dynamically appends some fields to a form.
Using a submit button:
<input type = "submit" value = "More on this date" name = "more" onClick="AddText();">
i want to preserve these added fields if the page refreshed after clicking this button. Is this possible?
I really need your help. thanks.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------
var fieldCount = 2; #the first two fields
var fieldCount1 = 2;
function addSku() {
fieldCount++;
fieldCount1++;
var node=document.createTextNo de("GEAR (Enter SKU): ");
document.getElementById("f s").append Child(node );
var newFriend = document.createElement('in put');
newFriend.type = 'text';
newFriend.size = '17';
newFriend.value = '';
newFriend.onFocus = this.value="";
newFriend.name = 'sku' + fieldCount;
newFriend.id = 'sku' + fieldCount;
document.getElementById('f s').append Child(newF riend);
var node=document.createTextNo de(" ");
document.getElementById("f s").append Child(node );
var newFriend1 = document.createElement('in put');
newFriend1.type = 'checkbox';
newFriend1.name = 'gear' + fieldCount1;
newFriend1.id = 'gear' + fieldCount1;
document.getElementById('f s').append Child(newF riend1);
var node=document.createTextNo de(" Review?");
document.getElementById("f s").append Child(node );
var newFriend2 = document.createElement('br ');
document.getElementById('f s').append Child(newF riend2);
}
Using a submit button:
<input type = "submit" value = "More on this date" name = "more" onClick="AddText();">
i want to preserve these added fields if the page refreshed after clicking this button. Is this possible?
I really need your help. thanks.
--------------------------
var fieldCount = 2; #the first two fields
var fieldCount1 = 2;
function addSku() {
fieldCount++;
fieldCount1++;
var node=document.createTextNo
document.getElementById("f
var newFriend = document.createElement('in
newFriend.type = 'text';
newFriend.size = '17';
newFriend.value = '';
newFriend.onFocus = this.value="";
newFriend.name = 'sku' + fieldCount;
newFriend.id = 'sku' + fieldCount;
document.getElementById('f
var node=document.createTextNo
document.getElementById("f
var newFriend1 = document.createElement('in
newFriend1.type = 'checkbox';
newFriend1.name = 'gear' + fieldCount1;
newFriend1.id = 'gear' + fieldCount1;
document.getElementById('f
var node=document.createTextNo
document.getElementById("f
var newFriend2 = document.createElement('br
document.getElementById('f
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If someone fills out an form and did not add all info or something was incorrect, you want to display back to the what they typed - is that correct?????
(reload the form with original info intact?)
Do you have PHP avail?
(reload the form with original info intact?)
Do you have PHP avail?
ASKER
thanks to everyone who answered
ASKER
i used a button instead, so definitely the page would not be refreshed. It has an "onclick" attribute which calls a function in javascript to retrieve the data from the fields. javascript-perl connection is done through ajax.
<body onload="addSku()">