PDA

View Full Version : when I do reset form this hidden field go to empty...



lse123
Mar 3rd, 2007, 11:03 AM
I make an html form[sub page] with a hidden field fill out from a cookie from home-page , well I want this field go to confirm page & email from form .... and that is comes BUT when I do reset form this field go to empty, well what to do when reset no go to empty but keep the cookie value ?

I am using frontpag2002 and dreamweaver mx 2004

BarrMan
Mar 3rd, 2007, 11:15 AM
Well, The option reset values clears all values in the form so it will clear the hidden value no matter what you do. You can, however, make an onClick event on the reset button which adds that value back.

lse123
Mar 3rd, 2007, 02:16 PM
How I do this if code is the below:

<script language="JavaScript" type="text/JavaScript">
<!--
var cookie = document.cookie;

var array = cookie.split(';');
var array = array[0].split('=');
var affvalue = array[1];

// var array = cookie.split('=');
// var affvalue = array[1];
document.write("You book through affiliate ID: " + affvalue );
-->
</script>

<input type="hidden" name="affiliate" />
<script language="JavaScript" type="text/JavaScript">
<!--
document.FrontPage_Form1.affiliate.value = affvalue;
-->
</script>

BarrMan
Mar 3rd, 2007, 04:51 PM
Try this:

<input type="hidden" name="affiliate" onChange="this.value=array[1];" />

lse123
Mar 6th, 2007, 08:08 AM
If onchange event reloads page also works ?

lse123
Mar 6th, 2007, 08:09 AM
give example

glenngv
Mar 6th, 2007, 02:56 PM
Form reset sets all the fields to their original values when the form is initially displayed. Since your hidden field is empty by default, it clears out when the form is reset. What you can do is to have a manual reset button (not input type=reset) and save the last value of the hidden field before resetting the form and then set the value back to the hidden field.

<script type="text/javascript">
function resetForm(oFrm){
var temp = oFrm.affiliate.value;
oFrm.reset(); //reset form
oFrm.affiliate.value = temp;
}
...
<input type="button" value="Reset" onclick="resetForm(this.form);" />

lse123
Mar 9th, 2007, 07:47 AM
<input type="hidden" name="affiliate" onChange="this.value=array[1];" />

No work --- same result --- when reset hidden field is empty, ....

glenngv
Mar 12th, 2007, 06:44 PM
Have you tried my solution in post #7 above?