Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to refer to a value of an input box within the <input...> tag?

Reply
Thread Tools

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

 
 
chirs
Guest
Posts: n/a
 
      10-17-2003
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
 
 
 
 
kaeli
Guest
Posts: n/a
 
      10-17-2003
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
> 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
 
 
 
 
Hywel Jenkins
Guest
Posts: n/a
 
      10-17-2003
In article <(E-Mail Removed) >,
(E-Mail Removed) says...
> 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.

> 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
 
Sergey I.Grachyov
Guest
Posts: n/a
 
      10-18-2003
Use this:

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

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


> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Width of text input box vs. password input box cjl HTML 1 10-31-2005 11:46 AM
Off Topic: Width of text input box vs. password input box cjl Javascript 7 10-30-2005 10:11 PM
Pass input Array value to function to calc different input value Susan Cranford Javascript 2 07-05-2005 02:53 AM
hide the input box or change the color of input box in html ashutosh Java 3 06-16-2005 02:21 PM



Advertisments