Auto Populate Text Box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • C. David Rossen

    Auto Populate Text Box

    Hello:

    I have a registration form for classes. Each class has a fee. I have a
    drop down box whereby the user chooses his class. There is a textbox with
    the associated fee. I would like to auto populate the fee textbox depending
    on what class the user chooses. In the email, the value of the drop down
    box has to be the name of the class and the value of the fee text box has to
    be the fee. Can someone please help me in accomplishing this? Thank you.

    David


  • Lee

    #2
    Re: Auto Populate Text Box

    C. David Rossen said:[color=blue]
    >
    >Hello:
    >
    >I have a registration form for classes. Each class has a fee. I have a
    >drop down box whereby the user chooses his class. There is a textbox with
    >the associated fee. I would like to auto populate the fee textbox depending
    >on what class the user chooses. In the email, the value of the drop down
    >box has to be the name of the class and the value of the fee text box has to
    >be the fee. Can someone please help me in accomplishing this? Thank you.[/color]

    You may not really want to do that.
    It would be trivial to hack your page to make it send your
    form with whatever class one wants, and whatever price they
    choose to pay for it. And I really hope you're not asking
    people to send personal/financial information through email.

    However:

    <html>
    <head>
    <script type="text/javascript">
    function populate(item){
    for(var i=0;i<item.form .elements.lengt h;i++){
    if(item==item.f orm.elements[i]){
    item.form.eleme nts[i+1].value=
    item.options[item.selectedIn dex].value;
    }
    }
    }
    </script>
    </head>
    <body>
    <form>

    <select onchange="popul ate(this)">
    <option value="">--none--</option>
    <option value="2.50">al pha</option>
    <option value="1.95">be ta</option>
    <option value="3.00">ga mma</option>
    </select>
    <input type="text"><br >

    <select onchange="popul ate(this)">
    <option value="">--none--</option>
    <option value="2.50">al pha</option>
    <option value="1.95">be ta</option>
    <option value="3.00">ga mma</option>
    </select>
    <input type="text"><br >

    <select onchange="popul ate(this)">
    <option value="">--none--</option>
    <option value="2.50">al pha</option>
    <option value="1.95">be ta</option>
    <option value="3.00">ga mma</option>
    </select>
    <input type="text"><br >

    </form>
    </body>
    </html>

    Comment

    • C. David Rossen

      #3
      Re: Auto Populate Text Box

      Lee:
      Here is the problem. I need the value of the class (alpha, beta or gamma)
      to be just that in the email, not the fee amount. So, my question is is
      there a way to populate the fee text box with the number while maintaining
      the value of the name of the class? Thanks.

      David

      "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
      news:bkqstu01na l@drn.newsguy.c om...[color=blue]
      > C. David Rossen said:[color=green]
      > >
      > >Hello:
      > >
      > >I have a registration form for classes. Each class has a fee. I have a
      > >drop down box whereby the user chooses his class. There is a textbox[/color][/color]
      with[color=blue][color=green]
      > >the associated fee. I would like to auto populate the fee textbox[/color][/color]
      depending[color=blue][color=green]
      > >on what class the user chooses. In the email, the value of the drop down
      > >box has to be the name of the class and the value of the fee text box has[/color][/color]
      to[color=blue][color=green]
      > >be the fee. Can someone please help me in accomplishing this? Thank[/color][/color]
      you.[color=blue]
      >
      > You may not really want to do that.
      > It would be trivial to hack your page to make it send your
      > form with whatever class one wants, and whatever price they
      > choose to pay for it. And I really hope you're not asking
      > people to send personal/financial information through email.
      >
      > However:
      >
      > <html>
      > <head>
      > <script type="text/javascript">
      > function populate(item){
      > for(var i=0;i<item.form .elements.lengt h;i++){
      > if(item==item.f orm.elements[i]){
      > item.form.eleme nts[i+1].value=
      > item.options[item.selectedIn dex].value;
      > }
      > }
      > }
      > </script>
      > </head>
      > <body>
      > <form>
      >
      > <select onchange="popul ate(this)">
      > <option value="">--none--</option>
      > <option value="2.50">al pha</option>
      > <option value="1.95">be ta</option>
      > <option value="3.00">ga mma</option>
      > </select>
      > <input type="text"><br >
      >
      > <select onchange="popul ate(this)">
      > <option value="">--none--</option>
      > <option value="2.50">al pha</option>
      > <option value="1.95">be ta</option>
      > <option value="3.00">ga mma</option>
      > </select>
      > <input type="text"><br >
      >
      > <select onchange="popul ate(this)">
      > <option value="">--none--</option>
      > <option value="2.50">al pha</option>
      > <option value="1.95">be ta</option>
      > <option value="3.00">ga mma</option>
      > </select>
      > <input type="text"><br >
      >
      > </form>
      > </body>
      > </html>
      >[/color]


      Comment

      Working...