473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Q: Form widget default value

Given the following example, I want "Jane Doe" to appear
when the user first views the form, and when he leaves it blank:

// ----------------
<FORM .... >
Name:
<INPUT TYPE="text" NAME="user_name" VALUE="Jane Doe"
SIZE="25" MAXLENGTH="30" REQUIRED="YES">
// ----------------

I presume it needs an event handler
using "onselect" and/or "onblur", or something like that,
but I have no idea what the specifics are,
and I'm trying to avoid creating a function for it!

I figure there *has* to be a simple way of doing the above!

I scoured the net and couldn't find anything useful,
but if you know of a helpful URL, then, by all means,
please tell me what it is!

Any help would be appreciated!

Thanks!

-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
Jul 23 '05 #1
3 1275
James Bond 007 wrote:
Given the following example, I want "Jane Doe" to appear
when the user first views the form, and when he leaves it blank:

// ----------------
<FORM .... >
Name:
<INPUT TYPE="text" NAME="user_name" VALUE="Jane Doe"
SIZE="25" MAXLENGTH="30" REQUIRED="YES">
// ----------------

I presume it needs an event handler
using "onselect" and/or "onblur", or something like that,
but I have no idea what the specifics are,
and I'm trying to avoid creating a function for it!

I figure there *has* to be a simple way of doing the above!

I scoured the net and couldn't find anything useful,
but if you know of a helpful URL, then, by all means,
please tell me what it is!

Any help would be appreciated!

Thanks!

-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
007 -

Well, one way or another, you'll be using a function for
this...probably meant a separately declared (global) function.

Could you elaborate on this?
I want "Jane Doe" to appear when the user first
views the form, and when he leaves it blank:


Jul 23 '05 #2
On 29 Apr 2005 08:23:27 -0700, "RobB" <fe******@hotmail.com> wrote:
James Bond 007 wrote:
Given the following example, I want "Jane Doe" to appear
when the user first views the form, and when he leaves it blank:

// ----------------
<FORM .... >
Name:
<INPUT TYPE="text" NAME="user_name" VALUE="Jane Doe"
SIZE="25" MAXLENGTH="30" REQUIRED="YES">
// ----------------

I presume it needs an event handler
using "onselect" and/or "onblur", or something like that,
but I have no idea what the specifics are,
and I'm trying to avoid creating a function for it!

I figure there *has* to be a simple way of doing the above!

I scoured the net and couldn't find anything useful,
but if you know of a helpful URL, then, by all means,
please tell me what it is!

Any help would be appreciated!

Thanks!

-----
Bond . . . James Bond
007 -

Well, one way or another, you'll be using a function for
this...probably meant a separately declared (global) function.

Could you elaborate on this?


I came up with the following,
but it doesn't re-fill the default value
if the user leaves the box blank
(the Reset function does that,
but I don't want the user to have to do that):

// (purposely omitted stuff)

// if field is blank, then show alert
function formCheck() {
if (document.myform.name.value=="") }
alert("Please fill-in ALL the boxes!");
return false;
}

// (purposely omitted stuff)

// call formCheck (above) when user hits "Submit" button
<FORM NAME="myform" METHOD="POST" ACTION="(cgi)"
onSubmit="return formCheck()">

// (purposely omitted stuff)

<INPUT NAME="name" TYPE="text" MAXLENGTH="35" SIZE="35"
required="YES" VALUE="Jane Doe">

I'm thinking that just after the "VALUE" part, in the above line,
there should be something like this:

onExitFromField="(if value is blank then 'alert' and reset to
"Jane Doe")"

Now, if someone could tell me what the above line
should *really* look like . . . !!!

Thanks!

-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
Jul 23 '05 #3
James Bond 007 wrote:
[snip]

<INPUT NAME="name" TYPE="text" MAXLENGTH="35" SIZE="35"
required="YES" VALUE="Jane Doe">

I'm thinking that just after the "VALUE" part, in the above line,
there should be something like this:

onExitFromField="(if value is blank then 'alert' and reset to
"Jane Doe")"

http://www.apptools.com/examples/dyn...enthandler.php

Mick
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Schmidt | last post by:
I'm trying to make a custom entry widget, as in the code that follows. There are two problems I'm trying to fix: 1) I would like the widget to behave as myEntry.Escape() does now, except that it...
6
by: William Gill | last post by:
I am trying to get & set the properties of a widget's parent widget. What I have works, but seems like a long way around the block. First I get the widget name using w.winfo_parent(), then i...
4
by: James Bond 007 | last post by:
I am a novice to Javascript (can do simple text-based pop-ups, but not familiar with variable manipulation). I would like to have a Javascript that gives me the start time (I don't care about...
10
by: Doug O'Leary | last post by:
Hey, all. I have a perl script which generates the html listed below. I cleaned it up a bit since the perl CGI module creates some really ugly html code. I've looked at this thing 8 ways to...
4
by: sullivanz.pku | last post by:
Hi all I am using the standard python GUI Tkinter as my program's main interface. Although I know wxPython has some widget to support rich text widget, but I do not have time to shift to wx----...
0
by: Tim N. van der Leeuw | last post by:
Hi, I need to display some hierarchical data, and because I don't want to force users to install too many things beyond Python itself, I'm hoping to use Tix which is at least included with...
1
by: pquodling | last post by:
I have an interesting Challenge - It is effectively an inventory system but with a twist. For each client, I need to track, let's call them containers. each of these containers logically...
2
by: Mudcat | last post by:
I am trying to change the width of a widget based on pixel size and not on characters. I can't figure out how to do this. Normally to change to the size of a widget it looks like: ...
1
by: printline | last post by:
Hello All I'm a newbee to javascript/ajax. I have produced a form, where i want to do some validation on some fields. I have used the spry framework and it works fine. Now, i have a select...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.