0
votes

I have a simple HTML form that when I hit submit. Posts it's data on the action page. What I want to know is on my action page is it possible I can output my select text and it's value?

For example when I hit submit on my form page. I want this data to go to my action page.

<form action="actionpage.cfm" method="post">
 <label for="emaillist">Email List</label>
 <select name="emaillist">
   <option value="[email protected]">Test 1</option>
   <option value="[email protected]">Test 2</option>
   <option value="[email protected]">Test 3</option>
   <option value="[email protected]">Test 4</option>
 </select>
 <input type="submit" value="SEND">
</form>

so on my action page. I want the outputted selects value to go to the cfmails to and the selects text to go to the emails subject header so it'll show up as so.

Subject: Test 1: [email protected]

I do not want Test 1 to be manually typed I want it outputted from the select tag that was submitted with the form.

I thought about reassigning the names value but that would also reassign value that it currently has when the form was submitted wouldn't it? Also I do not want to create another select box.

1
No, not without collecting that data via javascript and sending them to hidden inputs or submitting with ajax. that's simply not how html selects work. - Kevin B
Alright thank you. You gave me an idea I can probably collect the text of what the user clicked on for the option for the select tag and submit it to a hidden input that will post to the action page. - Curious13

1 Answers

1
votes

Two quick things.

  1. You need to add the method="post" to post data.
  2. The web page sends over whatever is in the value field. If you want more data, you have to put it in the value attributes

    <form action="actionpage.cfm" method="post">
      <label for="emaillist">Email List</label>
      <select name="emaillist">
        <option value="Test 1 [email protected]">Test 1</option>
        <option value="Test 2 [email protected]">Test 2</option>
        <option value="Test 3 [email protected]">Test 3</option>
        <option value="Test 4 [email protected]">Test 4</option>
      </select>
      <input type="submit" value="SEND">
    </form>