Welcome Guest ( Log In | Register )

      
Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Spyware, virus, trojan, fake security or privacy alerts? Read the malware cleaning guide.
 
Reply to this topicStart new topic
Save text-input value checkbox, How do I go about doing this with cookies?
lem.rar
post May 4 2008, 12:29 AM
Post #1


Member
**
Posts: 93
OS: Windows XP Pro, Windows Server 2003



Okay, javascript would be prefferable: I would like to make a checkbox that when checked will save the value of an input field. Such as "name".
I just started learning javascript, and I am testing things out, however if you could gimme a script straight-up I would be more than greatful!

It only needs to recall / remember 1 text-input field.
Go to the top of the page
 
+Quote Post
Metallica
post May 4 2008, 03:54 AM
Post #2


Spyware Veteran
Group Icon
Posts: 20,720
From: Netherlands
OS: XP Pro & Vista Ultimate



Hi lem.rar,

If I understand correctly you want to have a form where people can select one item and somethjing needs to be done with that.

A few questions:
- will al the fileds have the same name and just a different value.
- should the choice be one and one only (radiobuttons would be easier in such a case)
- will the resulting action be taken on the same page or does the value need to be transporte to the next?
- do you already have an idea how you want it to look? (makes it easier to adapt the script to you specific wishes)
Go to the top of the page
 
+Quote Post
lem.rar
post May 4 2008, 04:11 AM
Post #3


Member
**
Posts: 93
OS: Windows XP Pro, Windows Server 2003



1. The value will by defined by the user, specifically "name", the only value I want to be saved.
2. A checkbox for on / off, however a radio button would be fine.
3. I'm hoping it won't touch the submission...
4. Yes, I want it to go beside the name field, right after the input text

This is what I'll be applying it to: http://b64.ath.cx/maruchan/imgboard/index.htm
Go to the top of the page
 
+Quote Post
Metallica
post May 4 2008, 05:09 AM
Post #4


Spyware Veteran
Group Icon
Posts: 20,720
From: Netherlands
OS: XP Pro & Vista Ultimate



The checkbox for the file upload?
CODE
<label><input type=checkbox name=textonly value=on>No File </label>


If it is checked you want to store the value in the upfile field
<input type=file name=upfile size="35">

Is that correct? And what do you want to happen when it gets checked?
Go to the top of the page
 
+Quote Post
lem.rar
post May 4 2008, 05:20 AM
Post #5


Member
**
Posts: 93
OS: Windows XP Pro, Windows Server 2003



<input type=checkbox name=namesave value=on>

I just made this one.

When it gets checked I want it to save the value that the user puts into <input type=text name=name size="28"> via a cookie, so the users don't have to type it everytime they make a post.
Go to the top of the page
 
+Quote Post
Metallica
post May 4 2008, 07:40 AM
Post #6


Spyware Veteran
Group Icon
Posts: 20,720
From: Netherlands
OS: XP Pro & Vista Ultimate



OK . Then this should help:
http://www.quirksmode.org/js/cookies.html

You can use an onClick event triggered by the checkbox to start the
function createCookie

and a onload event in the body to start the:
function readCookie

example using the functions described at quirksmode:

<body onload="readCookie(name)">

<input type=checkbox name=namesave onClick="createCookie(name,value,days)">
Go to the top of the page
 
+Quote Post
lem.rar
post May 4 2008, 08:01 AM
Post #7


Member
**
Posts: 93
OS: Windows XP Pro, Windows Server 2003



I can't get it to work ;_; I'm trying to get it to work via a PHP script... Here is a segment of the relevant code...

CODE
$dat.='
<table cellpadding=1 cellspacing=1>
<tr><td bgcolor=#eeaa88><b>Name</b></td><td><input type=text name=name size="28" value="readCookie(name)"> <input type=checkbox name=namesave onClick=createcookie("name,value,days")></td></tr>
<tr><td bgcolor=#eeaa88><b>E-mail</b></td><td><input type=text name=email size="28"></td></tr>
<tr><td bgcolor=#eeaa88><b>Subject</b></td><td><input type=text name=sub size="35">
<input type=submit value="Submit"></td></tr>
<tr><td bgcolor=#eeaa88><b>Comment</b></td><td><textarea name=com cols="48" rows="4" wrap=soft></textarea></td></tr>
';


I don't think I'm able to use the single quotation marks. I'm truly clueless now.

This post has been edited by lem.rar: May 4 2008, 08:42 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   5 / 1,007 11th January 2006 - 05:50 AM
shawn_programing started - last by Hai Mac
No New Posts 1 / 39 Today, 08:36 AM
Clinetyme started - last by starjax
No New Posts   3 / 72 Today, 04:18 PM
tWiStEdArRow started - last by charge06
No New Posts   0 / 8 Today, 12:07 PM
newnoi started - last by newnoi

RSS Time is now: 1st December 2008 - 11:06 PM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.