Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Save text-input value checkbox


  • Please log in to reply

#1
lem.rar

lem.rar

    Member

  • Member
  • PipPip
  • 94 posts
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.
  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
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)
  • 0

#3
lem.rar

lem.rar

    Member

  • Topic Starter
  • Member
  • PipPip
  • 94 posts
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/ma...board/index.htm
  • 0

#4
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
The checkbox for the file upload?
<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?
  • 0

#5
lem.rar

lem.rar

    Member

  • Topic Starter
  • Member
  • PipPip
  • 94 posts
<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.
  • 0

#6
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
OK . Then this should help:
http://www.quirksmod...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)">
  • 0

#7
lem.rar

lem.rar

    Member

  • Topic Starter
  • Member
  • PipPip
  • 94 posts
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...

$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.

Edited by lem.rar, 04 May 2008 - 08:42 AM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP