We help IT Professionals succeed at work.
Get Started

Dropdown menus instead textarea - jquery

Zado asked
Last Modified: 2012-08-12
Hi Experts,

Here's my code:
<!doctype html>
<script type="text/javascript" src="js/jquery.js"></script>
<textarea style="width:700px; height:200px" id="optinform">
<form method="post" action="http://www.aweber.com/scripts/addlead.pl" onsubmit="wps_ref(this)" class="wpsform">
    <input id="test" type="hidden" name="meta_web_form_id" value="1771438030">
    <input type="hidden" name="meta_split_id" value="">
    <input type="hidden" name="listname" value="generation_wso">
    <input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text">
    <input type="hidden" name="meta_adtracking" value="Generation_Plugin_buyers">
    <input type="hidden" name="meta_message" value="1">
    <input type="hidden" name="meta_required" value="name,email">
    <input type="hidden" name="meta_tooltip" value="">
    <input type="checkbox" name="checkboxname" value="checked">
    <input type="text" class="name_field" name="name" value="sam" size="20">
    <input type="text" class="email_field" name="email" value="Zado1984@gmail.com" size="20">
    <input type="text" class="email_field" name="email" value="Zado1984@gmail.com" size="20">
    <input type="submit" name="submit" value="" class="submit_field">

<div id="formarea" style="display:none"></div>

<input type="button" value="proccess" id="proccess"><br/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$("#proccess").click(function(e) {
	//reset textareas
	$('#formaction').val($('#formarea form').attr('action'));
	$('input', '#formarea').each(function() {
		//proccess the form
		var field = 'otherfields';
		if ($(this).attr('type') == 'hidden') field = 'hiddenfields';
		if ($(this).attr('type') == 'text') field = 'regularfields';
		if ($(this).attr('type') == 'submit') field = 'submitbutton';
		$('#' + field).val($('#' + field).val() + '<input type="' + $(this).attr('type') + '" name="' + $(this).attr('name') + '" value="'+ $(this).val() +'" />\n');

<textarea style="width:700px; height:200px" id="formaction"></textarea><br/>

<textarea style="width:700px; height:200px" id="regularfields"></textarea><br/> 
instead the textarea above I need two dropdown fields, where in first one there's first detected
text input selected and in second one there's second detected text field selected:
	<!-- list of all text inputs, first one selected -->
	<!-- list of all text inputs, second one selected -->

<textarea style="width:700px; height:200px" id="hiddenfields"></textarea><br/>
<textarea style="width:700px; height:200px" id="otherfields"></textarea><br/>
<textarea style="width:700px; height:200px" id="submitbutton"></textarea><br/>

Open in new window

And it's all explain inside of the code in html comments:
I need to change the jquery script there and instead dropping all the text inputs into textarea, drop them into select, display each input as separate option.
Hope that's clear.

Thanks for any help.
Watch Question
Most Valuable Expert 2017
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE