Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #7588

Clear field with Javascript - use of variable?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From "Garry Jones" <garry@garryjones.se>
Newsgroups comp.lang.javascript
Subject Clear field with Javascript - use of variable?
Date Fri, 21 Oct 2011 00:27:23 +0200
Organization A noiseless patient Spider
Lines 1
Message-ID <j7q78d$mn7$1@dont-email.me> (permalink)
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="utf-8"; reply-type=original
Content-Transfer-Encoding 7bit
Injection-Date Thu, 20 Oct 2011 22:27:25 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="fOVkFHcZjyAK/d17IuVcwA"; logging-data="23271"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+a9n8hmBMArOLbWsPeEwd7GSUkpXyi/GA="
X-MimeOLE Produced By Microsoft MimeOLE V15.4.3538.513
X-Antivirus-Status Clean
X-Newsreader Microsoft Windows Live Mail 15.4.3538.513
Importance Normal
X-Antivirus avast! (VPS 111020-2, 2011-10-20), Outbound message
Cancel-Lock sha1:eSogcHIaVvB2My2UyiZNXv4I7y8=
X-Priority 3
X-MSMail-Priority Normal
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:7588

Show key headers only | View raw


I need to expand a function and a user button that clears an input field and 
sets focus.

This works

<script language="JavaScript" type="text/javascript">
function cfld() {
    document.getElementById("newsinl").value="";
    document.getElementById("newsinl").focus();
}
</script>
<input maxLength="100" name="newsinl" id="newsinl" type="text" value="" 
size="100">
<a href="javascript:cfld();" >Clear field</a>

What I need to do is to have several more of these functions.

Instead of writing a seperate function for each input field I would like to 
use the same one and pass a variable from each link. Can someone point me in 
the right direction as I am having problems finding a good site with simple 
instructions for this.

Any help appreciated

Garry Jone
Expat, Sweden

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar


Thread

Clear field with Javascript - use of variable? "Garry Jones" <garry@garryjones.se> - 2011-10-21 00:27 +0200
  Re: Clear field with Javascript - use of variable? Tim Streater <timstreater@greenbee.net> - 2011-10-20 23:53 +0100
    Re: Clear field with Javascript - use of variable? Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-10-21 11:24 +0200
  Re: Clear field with Javascript - use of variable? Dr J R Stockton <reply1142@merlyn.demon.co.uk> - 2011-10-21 21:53 +0100
  Re: Clear field with Javascript - use of variable? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-22 01:17 +0200

csiph-web