assigning values to a field in HTML document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tauqir

    #1

    assigning values to a field in HTML document

    I am trying to do a simple thing: I have these two text fields in an
    HTML form. I want to assign the concatenated value to a TEXTAREA. Can
    someone help me with the syntax?

    <HTML>
    <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
    </SCRIPT>
    <table ALIGN="center" border="2" width="100%" cellspacing="8"
    cellpadding="0" >
    <FORM action="" method="POST">
    <Table border="0" width="75%" cellspacing="0" cellpadding="0"
    align="center">
    <TR>
    <td COLSPAN="1" width="40%"> <LABEL for="firstname" >First name:
    </LABEL>
    </td>
    <td COLSPAN="1">
    <font face="Verdana" size="1" color="red">*</font>
    <INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir">
    </td>
    </TR>
    <TR>
    <td COLSPAN="1" >
    <LABEL for="lastname"> Last name: </LABEL>
    </td>
    <td COLSPAN="1">
    <font face="Verdana" size="1" color="red">*</font>
    <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
    </td>
    </TR>
    <TR>
    <td COLSPAN="1">Tex t Area: </td>
    <td COLSPAN="1"> <TEXTAREA Name="Details" COLS="40",
    ROWS="5" size="20">
    <-- I want to see the concatenated value firstname + lastname as the
    value of this text area -->
    </TEXTAREA>
    <BR>
    </td> </TR> <TR>
    </TR> <TR>
    <td COLSPAN="1">
    <font face="Verdana" size="1" color="red">*=R equired Fields</font>
    </td>
    </TR>
    </TR>
    <TR>
    <td COLSPAN="1">
    <INPUT type="submit" value="Send" >
    <INPUT type="reset" >
    </td>
    </TR>
    </FORM>
    </TABLE>
    </TABLE>
    </HTML>

  • chotiwallah@web.de

    #2
    Re: assigning values to a field in HTML document


    Tauqir wrote:[color=blue]
    > I am trying to do a simple thing: I have these two text fields in an
    > HTML form. I want to assign the concatenated value to a TEXTAREA. Can
    > someone help me with the syntax?
    >
    > <HTML>
    > <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
    > </SCRIPT>
    > <table ALIGN="center" border="2" width="100%" cellspacing="8"
    > cellpadding="0" >
    > <FORM action="" method="POST">
    > <Table border="0" width="75%" cellspacing="0" cellpadding="0"
    > align="center">
    > <TR>
    > <td COLSPAN="1" width="40%"> <LABEL for="firstname" >First name:
    > </LABEL>
    > </td>
    > <td COLSPAN="1">
    > <font face="Verdana" size="1" color="red">*</font>
    > <INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir">
    > </td>
    > </TR>
    > <TR>
    > <td COLSPAN="1" >
    > <LABEL for="lastname"> Last name: </LABEL>
    > </td>
    > <td COLSPAN="1">
    > <font face="Verdana" size="1" color="red">*</font>
    > <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">
    > </td>
    > </TR>
    > <TR>
    > <td COLSPAN="1">Tex t Area: </td>
    > <td COLSPAN="1"> <TEXTAREA Name="Details"[/color]
    COLS="40",[color=blue]
    > ROWS="5" size="20">
    > <-- I want to see the concatenated value firstname + lastname as the
    > value of this text area -->
    > </TEXTAREA>
    > <BR>
    > </td> </TR> <TR>
    > </TR> <TR>
    > <td COLSPAN="1">
    > <font face="Verdana" size="1" color="red">*=R equired Fields</font>
    > </td>
    > </TR>
    > </TR>
    > <TR>
    > <td COLSPAN="1">
    > <INPUT type="submit" value="Send" >
    > <INPUT type="reset" >
    > </td>
    > </TR>
    > </FORM>
    > </TABLE>
    > </TABLE>
    > </HTML>[/color]

    document.getEle mentsByName("De tails").value =
    document.getEle mentsByName("fi rstname").value +
    document.getEle mentsByName("la stname").value

    Comment

    • RobG

      #3
      Re: assigning values to a field in HTML document

      Tauqir wrote:[color=blue]
      > I am trying to do a simple thing: I have these two text fields in an
      > HTML form. I want to assign the concatenated value to a TEXTAREA. Can
      > someone help me with the syntax?[/color]

      Your HTML is horrible, please post valid, minimal code (get rid of the
      table...) - it makes it much easier to offer help.

      When do you want the concatenated value written? I've set it to happen
      onchange. I guess you want "Details" to be firstname lastname? Or
      lastname, firstname?

      [...][color=blue]
      > <INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir">[/color]

      <INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir"
      onchange="
      this.form.Detai ls.value = this.value + ' '
      + this.form.lastn ame.value;
      ">

      [...][color=blue]
      > <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani">[/color]

      <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
      onchange="
      this.form.Detai ls.value = this.form.first name.value + ' '
      + this.value;
      ">

      [...][color=blue]
      > <TEXTAREA Name="Details" COLS="40" ROWS="5" size="20">[/color]

      <TEXTAREA Name="Details" COLS="40" ROWS="5" size="20"
      readonly>Tauqir Ghani</TEXTAREA>

      Setting it to readonly means that users can not edit it directly, but
      it will still be submitted with the form.

      Note that the onchange only fires when the text inputs lose focus, you
      may want to set it to fire on some other event.

      Fully functional code below:

      <HTML>
      <head><title>pl ay</title>
      </head><body>

      <FORM action="" method="POST">
      <LABEL for="firstname" >First name: </LABEL>
      <INPUT type="text" SIZE="30" NAME="firstname " VALUE= "Tauqir"
      onchange="
      this.form.Detai ls.value = this.value + ' '
      + this.form.lastn ame.value;
      ">
      <br>
      <LABEL for="lastname"> Last name: </LABEL>
      <INPUT type="text" SIZE="30" NAME="lastname" VALUE= "Ghani"
      onchange="
      this.form.Detai ls.value = this.form.first name.value + ' '
      + this.value;
      ">
      <br>
      <TEXTAREA Name="Details" COLS="40" ROWS="5" size="20"
      readonly>Tauqir Ghani</TEXTAREA>
      <br>
      <INPUT type="submit" value="Send" >
      <INPUT type="reset" >
      </FORM>
      </body></HTML>



      --
      Rob

      Comment

      • Tauqir

        #4
        Re: assigning values to a field in HTML document

        Thanks, and yes I admit the frivolous posting style. It was the first
        time I used a newsgroup to ask for help. Hope to repay by helping
        others.

        Comment

        • Tauqir

          #5
          Re: assigning values to a field in HTML document

          Thanks, gets me over the hump.

          Comment

          Working...