/    Sign up×
Community /Pin to ProfileBookmark

what’s the easiest way to empty input box (dom)?

[B]<input name=”textfield” type=”text” class=”input” id=”textfieldML” value=”Join here” size=”15″ onfocus=”getValue()” />
[/B]

…and in getValue:

[B]onfocus=”document.getElementById(“textfieldML”).innerHTML=””
[/B]

this doesn’t work, but i’m sure it’s something like this…^^

pff, ideas?!

[I]needless to say client side is not my strong side! (php/mysql if anything)[/I]

?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@hitecbillauthorDec 23.2007 — FIXED!

onfocus="if(value=='Join here')value='';"


?
Copy linkTweet thisAlerts:
@Ay__351_eDec 23.2007 —  <br/>
&lt;script type="text/javascript"&gt;
function getValue() {
var el = document.getElementById('textfieldML');
el.value="";
}
&lt;/script&gt;
&lt;input name="textfield" type="text" class="input" id="textfieldML" value="Join here" size="15" onfocus="getValue()" /&gt;
&lt;input name="textfield" type="text" class="input" id="textfieldML2" value="Join here" size="15" onfocus="document.getElementById('textfieldML2').value='' " /&gt;
Copy linkTweet thisAlerts:
@mrhooDec 23.2007 — Be simpler to put the 'join here' in a label, and default the value at ''.
Copy linkTweet thisAlerts:
@hitecbillauthorDec 24.2007 —  <br/>
&lt;script type="text/javascript"&gt;
function getValue() {
var el = document.getElementById('textfieldML');
el.value="";
}
&lt;/script&gt;
&lt;input name="textfield" type="text" class="input" id="textfieldML" value="Join here" size="15" onfocus="getValue()" /&gt;
&lt;input name="textfield" type="text" class="input" id="textfieldML2" value="Join here" size="15" onfocus="document.getElementById('textfieldML2').value='' " /&gt;
[/QUOTE]

ty ?

i like the second one as it works inline...seems a bit over the top to write a little function and then call it, for something that can be done within the input tag...and for such a small task ?
Copy linkTweet thisAlerts:
@hitecbillauthorDec 24.2007 — Be simpler to put the 'join here' in a label, and default the value at ''.[/QUOTE]
oh?

why a label?


[I]i ALWAYS prefer the most simplest solutions![/I]
×

Success!

Help @hitecbill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...