Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / April 2005



Tip: Looking for answers? Try searching our database.

Q: Form widget default value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Bond 007 - 29 Apr 2005 16:17 GMT
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.
RobB - 29 Apr 2005 16:23 GMT
> Given the following example, I want "Jane Doe" to appear
> when the user first views the form, and when he leaves it blank:
[quoted text clipped - 27 lines]
> 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:
James Bond 007 - 29 Apr 2005 23:28 GMT
>> Given the following example, I want "Jane Doe" to appear
>> when the user first views the form, and when he leaves it blank:
[quoted text clipped - 23 lines]
>> -----
>> 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.
Mick White - 30 Apr 2005 02:17 GMT
[snip]

> <INPUT NAME="name" TYPE="text" MAXLENGTH="35" SIZE="35"
>     required="YES" VALUE="Jane Doe">
[quoted text clipped - 4 lines]
>     onExitFromField="(if value is blank then 'alert' and reset to
> "Jane Doe")"

http://www.apptools.com/examples/dynamiceventhandler.php

Mick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.