HighDots Forums  

How to refer to a value of an input box within the <input...> tag?

Javascript JavaScript language (comp.lang.javascript)


Discuss How to refer to a value of an input box within the <input...> tag? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chirs
 
Posts: n/a

Default How to refer to a value of an input box within the <input...> tag? - 10-17-2003 , 05:23 PM






Hi,

I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie. How can I fix it?
<input type="text" name="box1" onblur=document.cookie="user=" +
box1.value>

Chris

Reply With Quote
  #2  
Old   
kaeli
 
Posts: n/a

Default Re: How to refer to a value of an input box within the <input...> tag? - 10-17-2003 , 07:34 PM






In article <4c22a744.0310171323.12e16e83 (AT) posting (DOT) google.com>,
yma (AT) kicon (DOT) com enlightened us with...
Quote:
Hi,

I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie. How can I fix it?
input type="text" name="box1" onblur=document.cookie="user=" +
box1.value

Chris

Try
<input type="text" name="box1" onblur="setCookie('user',this.value,'')">

The function setCookie is as follows.

function setCookie(cookieName, cookieValue, expireDate)
{
/* Pass in three strings - the name of the cookie, the value, and the
expire date.
Pass in a "" empty string for expireDate to set a session cookie
(no expires date).
Pass in any other date for expire as a number of days to be added
to today's date. */

if (expireDate == "")
{
expires = "";
}
else
{
expires = new Date();
expires.setDate(expires.getDate() + expireDate);
expires = expires.toGMTString();
}
document.cookie = cookieName+"="+cookieValue+";expires="+expires;
}

--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------


Reply With Quote
  #3  
Old   
Hywel Jenkins
 
Posts: n/a

Default Re: How to refer to a value of an input box within the <input...> tag? - 10-17-2003 , 07:52 PM



In article <4c22a744.0310171323.12e16e83 (AT) posting (DOT) google.com>,
yma (AT) kicon (DOT) com says...
Quote:
Hi,

I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie.
Hardly surprising - the syntax is wrong.

Quote:
How can I fix it?
input type="text" name="box1" onblur=document.cookie="user=" +
box1.value
<input type="text"
name="box1"
onblur="document.cookie='user=' + document.FormName.box1.value;">


--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php


Reply With Quote
  #4  
Old   
Sergey I.Grachyov
 
Posts: n/a

Default Re: How to refer to a value of an input box within the <input...> tag? - 10-17-2003 , 08:21 PM



Use this:

<input type="text" name="box1" onblur='document.cookie="user=" +
this.value'>

--
Sergey.
http://www.takereal.com/freelance/resume.asp


Quote:
Hi,

I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie. How can I fix it?
input type="text" name="box1" onblur=document.cookie="user=" +
box1.value

Chris



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.