Solved

textbox cleared

Posted on 2004-09-10
7
237 Views
Last Modified: 2010-04-06
hi

i have a textbox on form and by default "0" is displayed in the textbox.

wht i want is when the user clicks in the textbox "0" must be automatically cleared so that he doesnt have to delete it
manually.

thanks

sandy
0
Comment
Question by:sandeep437
7 Comments
 
LVL 4

Accepted Solution

by:
Neil_Simpson earned 125 total points
ID: 12031918
use javascript such as

onFocus=document.getElementById('textboxID').value = '';"

this.value=''; should also work I think.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 12033208
or simplified to:

<input name="textfield" type="text" value="0" onFocus="this.value=''">

0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 12033214
nah... didn't see Neil's 2nd comment, disregard my comment above, cheers
0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12034315
It might be nicer on the user to have:

<input name="textfield" type="text" value="0" onFocus="this.value = (this.value=='0'?'':this.value)">
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 12038671
Another possibility:

<form>
<input type='text' value='0' onFocus='this.select()'>
</form>

Vinny
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 68
Tool to email me when a website changes 29 106
I starting with php 12 95
WCAG audit tools 1 52
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now