Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2012, 01:10 AM   PM User | #1
howie2009
Regular Coder

 
howie2009's Avatar
 
Join Date: May 2009
Location: Ireland
Posts: 202
Thanks: 37
Thanked 0 Times in 0 Posts
howie2009 is an unknown quantity at this point
Clear input value on page load

Hi,
I was hoping someone could help. I need to clear a text input value when my page loads. any idea how I could do this with js or jquery? I need to set it to blank as oppose to reset it. It can clear all inputs if its easier. thanks guys!

Last edited by howie2009; 10-02-2012 at 01:20 AM..
howie2009 is offline   Reply With Quote
Old 10-02-2012, 01:30 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
??? So then why give it a non-blank value in the first place?

But yes, trivial.
Code:
<html>
<body>
<form id="theForm" ...>
    <input name="whatever" value="banana pudding" />
    ...
</form>
<script type="text/javascript">
(
  function( )
  {
      var form = document.getElementById("theForm");
      form.whatever.value = "";
  }
)( );
</script>
</body>
</html>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:11 PM.


Advertisement
Log in to turn off these ads.