InfaredFog
Technical User
Hey guys,
I've been working for a while with Mootools, trying to get cookies to work across multiple directories. I have an identical form in three directories:
that I would like to be populated via cookies if one of the other forms has been filled out.
Right now I'm testing stuff in:
and
This is the code I'm using, in a cookies.js file in the radtherm1 directory (where I also have the mootools.js file):
[tt]Window.addEvent( 'domready', function() {
if(Cookie.get("name")){
$('name').setProperty('value',Cookie.get ("name"));
}else{
$('name').setProperty('value','');
}
if(Cookie.get("email")){
$('email').setProperty('value',Cookie.get ("email"));
}else{
$('email').setProperty('value','');
}
if(Cookie.get("company")){
$('company').setProperty('value',Cookie.get ("company"));
}else{
$('company').setProperty('value','');
}
if(Cookie.get("address1")){
$('address1').setProperty('value',Cookie.get ("address1"));
}else{
$('address1').setProperty('value','');
}
if(Cookie.get("address2")){
$('address2').setProperty('value',Cookie.get ("address2"));
}else{
$('address2').setProperty('value','');
}
if(Cookie.get("city")){
$('city').setProperty('value',Cookie.get ("city"));
}else{
$('city').setProperty('value','');
}
if(Cookie.get("state")){
$('state').setProperty('value',Cookie.get ("state"));
}else{
$('state').setProperty('value','');
}
if(Cookie.get("zip")){
$('zip').setProperty('value',Cookie.get ("zip"));
}else{
$('zip').setProperty('value','');
}
if(Cookie.get("country")){
$('country').setProperty('value',Cookie.get ("country"));
}else{
$('country').setProperty('value','');
}
if(Cookie.get("phone")){
$('phone').setProperty('value',Cookie.get ("phone"));
}else{
$('phone').setProperty('value','');
}
$('make').addEvent ('click',function(e) {
Cookie.set ("name", $('name').getProperty('value'));
Cookie.set ("email", $('email').getProperty('value'));
Cookie.set ("company", $('company').getProperty('value'));
Cookie.set ("address1", $('address1').getProperty('value'));
Cookie.set ("address2", $('address2').getProperty('value'));
Cookie.set ("city", $('city').getProperty('value'));
Cookie.set ("state", $('state').getProperty('value'));
Cookie.set ("zip", $('zip').getProperty('value'));
Cookie.set ("country", $('country').getProperty('value'));
Cookie.set ("phone", $('phone').getProperty('value'));
message = new Element('div',{'id':'message'}).injectAfter('myForm').setHTML('cookies saved!');
});
});[/tt]
Then in each of the index files in radtherm1 and radtherm2, I have this:
[tt]<form action="register.php" method="post" id="myForm">
<input type="text" id="name" name="name" size="25">
<input type="text" id="email" name="email" size="25">
<input type="text" id="company" name="company" size="25">
<input type="text" id="address1" name="address1" size="25">
<input type="text" id="address2" name="address2" size="25">
<input type="text" id="city" name="city" size="25">
<input type="text" id="state" name="state" size="25">
<input type="text" id="zip" name="zip" size="25">
<input type="text" id="country" name="country" size="25">
<input type="text" id="phone" name="phone" size="25">
<input id="make" type="submit" value="Submit Form!" />
</form>[/tt]
The cookies work for each page individually (ie, if I input info, navigate away from the page and then back to that page, the form will be populated), but they don't work across both directories.
Any suggestions as to how I could get all directories to read the same cookies?
Thanks guys!
I've been working for a while with Mootools, trying to get cookies to work across multiple directories. I have an identical form in three directories:
that I would like to be populated via cookies if one of the other forms has been filled out.
Right now I'm testing stuff in:
and
This is the code I'm using, in a cookies.js file in the radtherm1 directory (where I also have the mootools.js file):
[tt]Window.addEvent( 'domready', function() {
if(Cookie.get("name")){
$('name').setProperty('value',Cookie.get ("name"));
}else{
$('name').setProperty('value','');
}
if(Cookie.get("email")){
$('email').setProperty('value',Cookie.get ("email"));
}else{
$('email').setProperty('value','');
}
if(Cookie.get("company")){
$('company').setProperty('value',Cookie.get ("company"));
}else{
$('company').setProperty('value','');
}
if(Cookie.get("address1")){
$('address1').setProperty('value',Cookie.get ("address1"));
}else{
$('address1').setProperty('value','');
}
if(Cookie.get("address2")){
$('address2').setProperty('value',Cookie.get ("address2"));
}else{
$('address2').setProperty('value','');
}
if(Cookie.get("city")){
$('city').setProperty('value',Cookie.get ("city"));
}else{
$('city').setProperty('value','');
}
if(Cookie.get("state")){
$('state').setProperty('value',Cookie.get ("state"));
}else{
$('state').setProperty('value','');
}
if(Cookie.get("zip")){
$('zip').setProperty('value',Cookie.get ("zip"));
}else{
$('zip').setProperty('value','');
}
if(Cookie.get("country")){
$('country').setProperty('value',Cookie.get ("country"));
}else{
$('country').setProperty('value','');
}
if(Cookie.get("phone")){
$('phone').setProperty('value',Cookie.get ("phone"));
}else{
$('phone').setProperty('value','');
}
$('make').addEvent ('click',function(e) {
Cookie.set ("name", $('name').getProperty('value'));
Cookie.set ("email", $('email').getProperty('value'));
Cookie.set ("company", $('company').getProperty('value'));
Cookie.set ("address1", $('address1').getProperty('value'));
Cookie.set ("address2", $('address2').getProperty('value'));
Cookie.set ("city", $('city').getProperty('value'));
Cookie.set ("state", $('state').getProperty('value'));
Cookie.set ("zip", $('zip').getProperty('value'));
Cookie.set ("country", $('country').getProperty('value'));
Cookie.set ("phone", $('phone').getProperty('value'));
message = new Element('div',{'id':'message'}).injectAfter('myForm').setHTML('cookies saved!');
});
});[/tt]
Then in each of the index files in radtherm1 and radtherm2, I have this:
[tt]<form action="register.php" method="post" id="myForm">
<input type="text" id="name" name="name" size="25">
<input type="text" id="email" name="email" size="25">
<input type="text" id="company" name="company" size="25">
<input type="text" id="address1" name="address1" size="25">
<input type="text" id="address2" name="address2" size="25">
<input type="text" id="city" name="city" size="25">
<input type="text" id="state" name="state" size="25">
<input type="text" id="zip" name="zip" size="25">
<input type="text" id="country" name="country" size="25">
<input type="text" id="phone" name="phone" size="25">
<input id="make" type="submit" value="Submit Form!" />
</form>[/tt]
The cookies work for each page individually (ie, if I input info, navigate away from the page and then back to that page, the form will be populated), but they don't work across both directories.
Any suggestions as to how I could get all directories to read the same cookies?
Thanks guys!