473,668 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1289
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******@hotma il.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...probabl y 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.myfor m.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="retur n 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
4926
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 happens on loss of focus, not when pressing Esc. 2) TABbing between multiple entry fields does undesired things with the selection, and with cursor placement. Can anyone offer any suggestions for how to fix this? I'm attemting to
6
10253
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 convert the name to a reference using nametowidget(). self.nametowidget(event.widget.winfo_parent()).hasChanged= True It works, but I can't help but think I'm missing a more direct route. Am I? Bill
4
9511
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 the date) when the user entered my webpage and then the time that the user hit the "Submit" button on my HTML form.
10
2834
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 Sunday, but I can't see anything wrong. When I hit the "Add" button, it immediately executes the action of the form skipping the validate_form function completely. I've tried the script section towards the top of the html as well as just before...
4
11540
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---- series. Does anyone know any Tkinter based widget that support: 1. Blod, Italic, Underline and their combinations. 2. Several most commonly used fonts, like Times New Roman and Arial 3. Multiline text 4. Cross platform support. Available in...
0
1499
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 Python. I've managed to use the Tix HList widget to display a tree of items (at least in a proof-of-concept miniprogram) but I actually need to display 2 columns -- perhaps more.
1
1478
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 contain, let's call them widgets. (widgets actually have a separate physical location, so the relationship is logical at first...) When a widget is consumed, I need to retain tracking of it. (as a) the billing is actually done on the "remaining...
2
11685
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: widget.configure(width = x) However that is in characters, not in pixels. To retrieve the actual size of a widget, I believe it is done with:
1
2226
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 list, where if i choose a certian option, more fields in the form will appear. My problem is only to validate on these fields if they are visible. I think that maybe some if - else statements will do the trick, but how do i implement these....? ...
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8382
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.