dynamically set textboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Dover - Mental Patient 0057

    dynamically set textboxes

    i want to be able to dynamically set different text boxes depending on
    the button pressed.


    i was hoping obj() can "become" object "aaa" or "bbb", but it's not
    working.

    function clearBox(inputo bject) {
    var obj=(inputobjec t);
    document.main.o jb().value="hel lo";
    document.main.a aa.focus();
    }


    ----------------
    <form name="main">
    <input type="text" value="aaa" name="boxaaa">
    <input type="text" value="bbb" name="boxbbb">
    <input type="button" value="clickme" onclick="clearB ox(aaa)">
    <input type="button" value="clickme" onclick="clearB ox(bbb)">
    </form>
  • Lasse Reichstein Nielsen

    #2
    Re: dynamically set textboxes

    Ben Dover - Mental Patient 0057 <Ben_Dover@psyc hiatric-center.Bellevue-Hospital.com> writes:
    [color=blue]
    > i want to be able to dynamically set different text boxes depending on
    > the button pressed.[/color]
    [color=blue]
    > i was hoping obj() can "become" object "aaa" or "bbb", but it's not
    > working.
    >
    > function clearBox(inputo bject) {
    > var obj=(inputobjec t);
    > document.main.o jb().value="hel lo";[/color]

    From the FAQ <URL:http://jibbering.com/faq/#FAQ4_39>

    document.forms['main'].elements[inputobject].value="hello";

    (I prefer to always use the forms and elements collections)

    This also requires that the remaining code is correct :
    [color=blue]
    > <input type="text" value="aaa" name="boxaaa">
    > <input type="text" value="bbb" name="boxbbb">
    > <input type="button" value="clickme" onclick="clearB ox(aaa)">[/color]
    onclick="clearB ox('aaa')"
    You want to send a string, not the value of the possibly non-existing
    global variable called "aaa".
    [color=blue]
    > <input type="button" value="clickme" onclick="clearB ox(bbb)">[/color]

    Ditto here.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Ben Dover - Mental Patient 0057

      #3
      Re: dynamically set textboxes

      just want to share with everyone what I put together:
      in the head:

      function clearBox(inputo bject) {
      var obj=(inputobjec t);
      document.main[inputobject].value="";
      document.main[inputobject].focus();
      }


      in the body:
      <form name="main" >
      <INPUT TYPE="TEXT" VALUE="hellowor ld" NAME="login">
      <a href="#" onclick="clearB ox('login');">c lear login</a>

      <INPUT TYPE="TEXT" VALUE="hellowor ld" NAME="password" >
      <a href="#" onclick="clearB ox('password'); ">clear password</a>

      etc...
      </form>


      have fun folks!

      Lasse Reichstein Nielsen wrote:[color=blue]
      >
      > Ben Dover - Mental Patient 0057 <Ben_Dover@psyc hiatric-center.Bellevue-Hospital.com> writes:
      >[color=green]
      > > i want to be able to dynamically set different text boxes depending on
      > > the button pressed.[/color]
      >[color=green]
      > > i was hoping obj() can "become" object "aaa" or "bbb", but it's not
      > > working.
      > >
      > > function clearBox(inputo bject) {
      > > var obj=(inputobjec t);
      > > document.main.o jb().value="hel lo";[/color]
      >
      > From the FAQ <URL:http://jibbering.com/faq/#FAQ4_39>
      >
      > document.forms['main'].elements[inputobject].value="hello";
      >
      > (I prefer to always use the forms and elements collections)
      >
      > This also requires that the remaining code is correct :
      >[color=green]
      > > <input type="text" value="aaa" name="boxaaa">
      > > <input type="text" value="bbb" name="boxbbb">
      > > <input type="button" value="clickme" onclick="clearB ox(aaa)">[/color]
      > onclick="clearB ox('aaa')"
      > You want to send a string, not the value of the possibly non-existing
      > global variable called "aaa".
      >[color=green]
      > > <input type="button" value="clickme" onclick="clearB ox(bbb)">[/color]
      >
      > Ditto here.
      >
      > /L
      > --
      > Lasse Reichstein Nielsen - lrn@hotpop.com
      > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      > 'Faith without judgement merely degrades the spirit divine.'[/color]

      Comment

      Working...