Auto Populate Values

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

    Auto Populate Values

    I have 4 possible values that I would like to populate a text box with
    depending on which 4 values are sleected in a select box. Is there an
    example out there for this?

    Thanks
    Frank



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Stuart Palmer

    #2
    Re: Auto Populate Values

    <script language="javas cript">
    function changetext(Drop down_Val, Dropdown_Val_SI )
    {
    switch (Dropdown_Val[Dropdown_Val_SI].value)
    {
    case 'Cheese' :
    document.MyForm .TextField.valu e="Cheese";
    break
    case 'Ham' :
    document.MyForm .TextField.valu e="Ham";
    break
    default :
    document.MyForm .TextField.valu e="No Value";
    break
    }
    }
    </script>

    <form name="MyForm">
    <select name="DropField " onChange="chang etext(this,this .selectedIndex) ;">
    <option value="Choose"> Choose</option>
    <option value="Ham">Ham </option>
    <option value="Cheese"> Cheese</option>
    </select>
    <input type="text" name="TextField ">
    </form>

    Stu

    "Frank Py" <fpy@proactnet. com> wrote in message
    news:3efde536$0 $199$75868355@n ews.frii.net...[color=blue]
    > I have 4 possible values that I would like to populate a text box with
    > depending on which 4 values are sleected in a select box. Is there an
    > example out there for this?
    >
    > Thanks
    > Frank
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • JHLeong

      #3
      Re: Auto Populate Values

      "Stuart Palmer" <tryandspamme@y oucant.com> wrote in message news:<hNwLa.285 $d67.6856@newsf ep2-gui.server.ntli .net>...[color=blue]
      > <script language="javas cript">
      > function changetext(Drop down_Val, Dropdown_Val_SI )
      > {
      > switch (Dropdown_Val[Dropdown_Val_SI].value)
      > {
      > case 'Cheese' :
      > document.MyForm .TextField.valu e="Cheese";
      > break
      > case 'Ham' :
      > document.MyForm .TextField.valu e="Ham";
      > break
      > default :
      > document.MyForm .TextField.valu e="No Value";
      > break
      > }
      > }
      > </script>
      >
      > <form name="MyForm">
      > <select name="DropField " onChange="chang etext(this,this .selectedIndex) ;">
      > <option value="Choose"> Choose</option>
      > <option value="Ham">Ham </option>
      > <option value="Cheese"> Cheese</option>
      > </select>
      > <input type="text" name="TextField ">
      > </form>
      >
      > Stu
      >
      > "Frank Py" <fpy@proactnet. com> wrote in message
      > news:3efde536$0 $199$75868355@n ews.frii.net...[color=green]
      > > I have 4 possible values that I would like to populate a text box with
      > > depending on which 4 values are sleected in a select box. Is there an
      > > example out there for this?
      > >
      > > Thanks
      > > Frank
      > >
      > >
      > >
      > > *** Sent via Developersdex http://www.developersdex.com ***
      > > Don't just participate in USENET...get rewarded for it![/color][/color]

      <form name="MyForm">
      <select name="DropField " onChange="docum ent.MyForm.Text Field.value =
      this.options[this.selectedIn dex].value;">
      <option value="">Choose </option>
      <option value="Ham">Ham </option>
      <option value="Cheese"> Cheese</option>
      </select>
      <input type="text" name="TextField ">
      </form>

      Comment

      • Evertjan.

        #4
        Re: Auto Populate Values

        JHLeong wrote on 30 jun 2003 in comp.lang.javas cript:
        [color=blue]
        > <form name="MyForm">
        > <select name="DropField " onChange="docum ent.MyForm.Text Field.value =
        > this.options[this.selectedIn dex].value;">
        > <option value="">Choose </option>
        > <option value="Ham">Ham </option>
        > <option value="Cheese"> Cheese</option>
        > </select>
        > <input type="text" name="TextField ">
        > </form>[/color]

        Nice and short, I changed it to:

        <select
        onChange="locat ion.href =
        this.options[this.selectedIn dex].value;">
        <option value="">Go to</option>
        <option value="http://cnn.com/">CNN</option>
        <option value="http://google.com/">Google</option>
        </select>



        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Evertjan.

          #5
          Re: Auto Populate Values

          Frank Py wrote on 30 jun 2003 in comp.lang.javas cript:
          [color=blue]
          > Thanks for the great examples. I just have one more question on this.
          > I'm using some sample code that uses ASP and the Response.Write to write
          > out all the html as it is called with functions. So when it hits the
          > first double quote in these examples, it thinks it the end of a state
          > ment:
          >
          > Response.Write "<tr><td>Da te</td>"
          >[/color]

          Use single quotes in javascript.

          =============== =============== ======

          or change

          Response.Write "<option value='http://google.com/'>Google</option>"

          to

          %><option value="http://google.com/">Google</option><%

          because why use Response.Write in stead of straight html here ????

          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          Working...