Forms - Select list not working, but check boxes do - forms

What is the error that is not allowing the below select list to work?
Creating an email sign up form (Constant Contact). Using the Constant Contact form generator, I attempted to change the "mailing lists options" from check boxes to a drop down menu—but doing so caused the contact info to be added to all the mailing lists, and not the single list that was selected.
Select list code: (not working)
<select>
<option name="Customer Type" ID="">Please select...</option>
<option value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />Architect/Designer</option>
<option value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />AV/Media/Broadcast</option>
<option value="Command/Control" name="Lists[]" id="list_Command/Control" />Command/Control</option>
</select>
Check box code: (working)
<input type="checkbox" checked="checked" value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />
<label for="list_Architect/Designer">Architect/Designer</label><br />
<input type="checkbox" value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />
<label for="list_AV/Media/Broadcast">AV/Media/Broadcast</label><br />
<input type="checkbox" value="Command/Control" name="Lists[]" id="list_Command/Control" />
<label for="list_Command/Control">Command/Control</label><br />

you need select to be multiple
<select multiple='multiple'>
<option name="Customer Type" ID="">Please select...</option>
<option value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />Architect/Designer</option>
<option value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />AV/Media/Broadcast</option>
<option value="Command/Control" name="Lists[]" id="list_Command/Control" />Command/Control</option>
</select>

Related

yii2 remove optgroup from dropdownlist

How can i remove the optgroup from a checkbox field
<?= $form->field($model, 'survey_type')->dropDownList([$surveyTypeList],['prompt'=>'Select Survey Type','id'=>'Survey_Type_dropdown']) ?>
provides following html
<label class="control-label" for="Survey_Type_dropdown">Type</label>
<select id="Survey_Type_dropdown" class="form-control" name="Surveys[survey_type]">
<option value="">Select Survey Type</option>
<optgroup label="0">
<option value="2D">2D</option>
<option value="3D">3D</option>
</optgroup>
</select>
<div class="help-block"></div>
You have to send $surveyTypeList as a variable, not a array.
Just remove [].

Form Calculator and display

is there anyway at all that i can get the number of lessons chosen to be multiplied by the lesson type and then displayed as a total near the form? It would be far easier for people filling out the form to have an automated calculation rather than having to have to calculate it themselves.
<h4>Lesson Form</h4>
<form action="mailer.php" data-validate="parsley" method="post" >
<p><strong>Full Name<span class="red">*</span></strong></p>
<input name="cf_name" data-required="true" class="send" type="text" />
<p><strong>Email Address<span class="red">*</span></strong></p>
<input name="cf_email" data-required="true" data-type="email" class="send" type="text" />
<p><strong>Cellphone No.<span class="red">*</span></strong></p>
<input name="cf_cell" data-required="true" class="send" type="text" />
<p><strong>Instrument Type<span class="red">*</span></strong></p>
<select name="cf_instrument" size="1" class="option" >
<option value="Piano">Piano</option>
<option value="Vocals">Vocals</option>
<option value="Guitar">Guitar</option>
<option value="Bass">Bass</option>
<option value="Flute">Flute</option></select>
<p><strong>Lesson Type<span class="red">*</span></strong></p>
<select name="cf_package_type" size="1" class="option">
<option value="Beginner Lesson - R100">Beginner Lesson - R100</option>
<option value="Advanced Lesson - R130">Advanced Lesson - R130</option>
<option value="Professional Lesson - R160">Professional Lesson - R160</option></select>
<p><strong>No. of Lessons<span class="red">*</span></strong></p>
<select id="number-of-lessons" name="cf_number" size="1" class="option" onchange='test()'>
<option value="1" selected="selected">1</option>
<option name="2" value="2">2</option>
<option name="3" value="3">3</option>
<option name="4" value="4">4</option></select>
<script src="js/datepair.js"></script>
<p><strong>Lesson Date & Time<span class="red">*</span></strong></p>
<p class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-2" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-3" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-4" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<!-- HIDDEN FIELD - HONEYPOT ANTI_SPAM -->
<input id="website" class="using" name="website" type="text" />
<!-- END -->
<input name="Submit" class="submit" value="Book Now" type="submit" /></form>
Would you so great if you could help me with this!
Here's a solution using Javascript.
explanation:
every time the option changes, I'm recalculating the multiplication of the chosen values.
HTML (simplified version of what you have. Notice how I changed the value of your options.)
<select id="lesson-type" onchange='calculate()'>
<option value="100">Beginner Lesson - R100</option>
<option value="130">Advanced Lesson - R130</option>
<option value="160">Professional Lesson - R160</option>
</select>
<select id="number-of-lessons" onchange='calculate()'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<label id="result"></label>
JS:
function calculate() {
var l_type = document.getElementById("lesson-type").value;
var num_lessons = document.getElementById("number-of-lessons").value;
document.getElementById("result").innerHTML = l_type * num_lessons;
}
Edit:
in this Example I also call the function once the page loads.
If you want to create simple web calculator with Javascript I would recommend you to take a look at “Appizy”.
It converts instantly a spreadsheet into a standalone web calculation tool in HTML+CSS+JAVASCRIPT. You don’t need to hardcode the whole interface and calculation formulas!
Just create your working calculator with Open- or LibreOffice and then use Appizy.
I hope it can help. Best,
Nicolas

Dynamically change form post action on submit

I am trying to have my form change post action dynamically based on a choice made in a dropdown once the user presses submit. i have gotten it to work once the choice is made, but that overrides my validation rules.
the url of the site I am working on is instaloan.glidewebdesign.com
based on a choice from the "Car Title Status" dropdown, I would like it submit a different post action based on the answer.
Thanks in advance for any and all help!!!!!!
function set_form_action()
{
if (page == 'clear_title')
{
window.location = 'https://secure.leads360.com/Import.aspx? Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you';
}
else if (page == 'lien_on_title')
{
window.location = 'https://secure.leads360.com/Import.aspx?Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you2';
}
else if (page == 'no_title')
{
window.location = 'https://secure.leads360.com/Import.aspx?Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.com/index.php/thank-you3';
}
}
<form name="homeform" >
<fieldset>
<input name="first" type="text" class="name" placeholder=" First Name" maxlength="10" onkeyup="checkInput2(this)" required="required" />
<input name="last" type="text" class="name" placeholder=" Last Name" maxlength="15" onkeyup="checkInput2(this)" required="required" /></br>
<input name="phone" type='tel' pattern='^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$' title='Phone Number (Format: (999) 999-9999)' class="name" placeholder=" Phone Number" maxlength="10" onkeyup="checkInput(this)" required="required" />
<input name="zip" type="text" name="zipCode" value=""
pattern="[0-9]{5}([-][0-9]{4})?" placeholder=" Zip Code" class="name" maxlength="5" onkeyup="checkInput(this)" required="required" /></br>
<select name="amount" class="dropdown" value="Amount Requested">
<option value="0">Amount</option>
<option value="$100-$499">$100 - $499</option>
<option value="$500-$999">$500 - $999</option>
<option value="$1000-$1999">$1,000 - $1,999</option>
<option value="$2000-$2999">$2,000 - $2,999</option>
<option value="$3000+">$3,000+</option>
</select>
</br>
<select name="status" class="dropdown" value="Car Title Status" >
<option value="smt">Car Title Status</option>
<option value="clear_title">I have a clear car title</option>
<option value="lien_on_title">There′s a lien against my car title</option>
<option value="no_title">I don′t have a car title</option>
</select>
</br>
<input name="submit" type="submit" class="submit" value="Find Out Now" />
</fieldset>
</form>
OK...after pulling out the little hair I have left, I got it figured out...waht I was doing was completely wrong, for what I am trying to accomplish anyway. This is my final working code:
$("#homeform").submit(function(){
if($("#status").val() == "clear_title"){
$(this).attr("action","https://secure.leads360.com/Import.aspx? Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co m/index.php/thank-you");
}
else if($("#status").val() == "lien_on_title"){
$(this).attr("action","https://secure.leads360.com/Import.aspx? Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co m/index.php/thank-you2");
}
else if($("#status").val() == "no_title"){
$(this).attr("action","https://secure.leads360.com/Import.aspx? Provider=TMXFinance&Client=TMXFinance&CampaignId=1034&Url=http://instaloan.glidewebdesign.co m/index.php/thank-you3");
}
});
HTML:
<form id="homeform" name="homeform" method="post" action="">
<fieldset>
<input name="first" type="text" class="name" placeholder=" First Name" maxlength="10" onkeyup="checkInput2(this)" required="required" />
<input name="last" type="text" class="name" placeholder=" Last Name" maxlength="15" onkeyup="checkInput2(this)" required="required" /></br>
<input id="phone" name="phone" type='tel' pattern='^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$' title='Phone Number (Format: (999) 999-9999)' class="name" placeholder=" Phone Number" maxlength="10" required="required" />
<input name="zip" type="text" name="zipCode" value=""
pattern="[0-9]{5}([-][0-9]{4})?" placeholder=" Zip Code" class="name" maxlength="5" onkeyup="checkInput(this)" required="required" /></br>
<select name="amount" class="dropdown" value="Amount Requested">
<option value="0">Amount</option>
<option value="$100-$499">$100 - $499</option>
<option value="$500-$999">$500 - $999</option>
<option value="$1000-$1999">$1,000 - $1,999</option>
<option value="$2000-$2999">$2,000 - $2,999</option>
<option value="$3000+">$3,000+</option>
</select>
</br>
<select id="status" name="status" class="dropdown" value="Car Title Status" >
<option value="smt">Car Title Status</option>
<option value="clear_title">I have a clear car title</option>
<option value="lien_on_title">There′s a lien against my car title</option>
<option value="no_title">I don′t have a car title</option>
</select>
</br>
<input name="submit" type="submit" class="submit" value="Find Out Now" />
</fieldset>
</form>

Why isn't newly selected option sent to server when form is submitted? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
I have a select tag that is built like this:
<%= f.select(:id, category_options, include_blank:true) %>
The form displays fine and the appropriate model item's option tag is selected. However, when the user selects a different option and submits the form, the new option is not passed to the server. Instead, the originally selected value is passed to the server.
The rails log shows the old values being submitted, not the new ones. The values for this input appear to be cached.This happens in development and production, and in development cache_classes = false.
The rails log like this:
Started PUT "/posts/1999" for 127.0.0.1 at 2012-09-11 13:42:51 -0400
Processing by GalleriesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"...", "gallery"=>{"publish_on"=>"2012-09-18", "poster_file_temp"=>"", "thumb_file_temp"=>"", "models_attributes"=>{"0"=>{"id"=>"116", "_destroy"=>"false"}, "1"=>{"id"=>"6409", "_destroy"=>"false"}}, "categories_attributes"=>{"0"=>{"id"=>"59", "_destroy"=>"false"}}, "thumb_zip_input"=>"", "medium_zip_input"=>"", "large_zip_input"=>"", "website_url"=>"", "commit"=>"Upload", "id"=>"1999"}
The form looks like this:
<form accept-charset="UTF-8" action="/galleries/1999" class="edit_gallery" enctype="multipart/form-data" id="edit_gallery_1999" method="post" name="edit_gallery_1999">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="...">
</div>
<div class="vert">
<label for="gallery_publish_on">Publish on</label> <input id="gallery_publish_on" name="gallery[publish_on]" size="30" type="text" value="2012-09-18"> <label for="gallery_poster_file">Poster file</label> <input id="gallery_poster_file_temp" name="gallery[poster_file_temp]" type="hidden"><input id="gallery_poster_file" name="gallery[poster_file]" size="30" type="file">
<div class='formSection'>
<img alt="Brandy" src="/content/gallery/poster_file/0000/1999/brandy.jpg">
</div><label for="gallery_thumb_file">Thumb file</label> <input id="gallery_thumb_file_temp" name="gallery[thumb_file_temp]" type="hidden"><input id="gallery_thumb_file" name="gallery[thumb_file]" size="30" type="file">
<div class='formSection'>
<img alt="Thumb" src="/content/gallery/thumb_file/0000/1999/thumb.jpg">
</div>
<div id="models">
<label for="Models">Models</label>
<div>
<select id="gallery_models_attributes_0_id" name="gallery[models_attributes][0][id]">
<option value="6409">
April
</option>
<option value="6366" selected="selected">
Brandy
</option>
<option value="9036">
Charlie
</option>
<option value="7490">
Craig
</option>
<option value="9881">
Donna
</option>
</select> <input id="gallery_models_attributes_0__destroy" name="gallery[models_attributes][0][_destroy]" type="hidden" value="false"> remove
</div><input id="gallery_models_attributes_0_id" name="gallery[models_attributes][0][id]" type="hidden" value="6366"> add model
</div>
<div id="categories">
<label for="Categories">Categories</label>
<div>
<select id="gallery_categories_attributes_0_id" name="gallery[categories_attributes][0][id]">
<option value="1">
Amateur
</option>
<option value="2">
Animals
</option>
<option value="49">
Articles
</option>
<option value="3">
Art
</option>
<option value="7">
Blog
</option>
</select> <input id="gallery_categories_attributes_0__destroy" name="gallery[categories_attributes][0][_destroy]" type="hidden" value="false"> remove
</div><input id="gallery_categories_attributes_0_id" name="gallery[categories_attributes][0][id]" type="hidden" value="59"> add category
</div>
<div id='photoset_files'>
<fieldset>
<legend>Zip Files</legend> <label for="gallery_thumb_zip_input">thumb zip</label> <select id="gallery_thumb_zip_input" name="gallery[thumb_zip_input]">
<option value="/Library/WebServer/Documents/uploads/thumb copy.zip">
thumb copy.zip
</option>
<option value="/Library/WebServer/Documents/uploads/thumb.zip">
thumb.zip
</option>
</select> [ thumb.zip ]<br>
<label for="gallery_medium_zip_input">medium zip</label> <select id="gallery_medium_zip_input" name="gallery[medium_zip_input]">
<option value="/Library/WebServer/Documents/uploads/medium copy 10.zip">
medium copy 10.zip
</option>
<option value="/Library/WebServer/Documents/uploads/medium copy 9.zip">
medium copy 9.zip
</option>
<option value="/Library/WebServer/Documents/uploads/medium copy.zip">
medium copy.zip
</option>
<option value="/Library/WebServer/Documents/uploads/medium.zip">
medium.zip
</option>
</select> [ medium.zip ]<br>
<label for="gallery_large_zip_input">large zip</label> <select id="gallery_large_zip_input" name="gallery[large_zip_input]">
<option value="/Library/WebServer/Documents/uploads/large copy 10.zip">
large copy 10.zip
</option>
<option value="/Library/WebServer/Documents/uploads/large copy 9.zip">
large copy 9.zip
</option>
<option value="/Library/WebServer/Documents/uploads/large copy.zip">
large copy.zip
</option>
<option value="/Library/WebServer/Documents/uploads/large.zip">
large.zip
</option>
</select> [ large.zip ]<br>
</fieldset>
</div><label for="gallery_website_url">Website url</label> <input class="wider" id="gallery_website_url" name="gallery[website_url]" size="30" type="text" value=""> <input id="tluo" name="tluo" type="hidden" value="aHR0cDovL2tmLmRldi9nYWxsZXJpZXMvbGlzdA==">
<div id="submit">
<input data-disable-with="Uploading..." name="commit" type="submit" value="Upload"> Cancel
</div>
</div>
</form>
This is because you are repeating the id and name attribute of select . This is not recommended to have two html elements with same id values
try to change name of select or if you want to use this as array then specifying name this way may help you out
gallery[categories_attributes][0][id][]
This one I used to collect checked radio button values, it may work in your case

Why my form is skipping every other item

I'm doing a project for a class, basically trying to do a survey to match people with a dorm based on their desired lifestyle. I copied the syntax for the form and some of them pop up correctly-the question appears with a drop down menu, but then the questions "how often do you plan on going to red lion" and "how do you plan on eating most of your meals" dont show up, and the options that should be in the drop down menu appear as text on the page, not as a drop down menu. any ideas? Heres the code:
<!DOCTYPE html>
<html>
<head>
<title> Find the right dorm for you </title>
<h1>Find out what dorm fits your lifestyle!</h1>
</head>
<body>
<p> Please fill out a few quesitons so we can help you figure out which dorm is best for you. </p>
<form method="get" action="slutsky1-results.php">
I enjoy (check all that apply):<br>
<input type="checkbox" name="act1" value="8">Working Out<br>
<input type="checkbox" name="act2" value="3">Bowling<br>
<input type="checkbox" name="act3" value="3">Live Music<br>
<input type="checkbox" name="act4" value="5">Shopping<br>
<input type="checkbox" name="act5" value="7">Food<br>
<input type="checkbox" name="act6" value="9">Bars <br>
<input type="checkbox" name="act7" value="9">Frat Parties <br>
<input type="checkbox" name="act8" value="8">Sports <br>
<input type="checkbox" name="act9" value="3">Library <br>
Is being close to the quad important to you?:
<select name= "Quad">
<option value="1">Not important</option>
<option value="3">Kind of important</option>
<option value="6">Very Important</option>
<option value="3">Only thing that matters</option> <br>
How often do you plan on going to Red Lion?:
<select name= "Lion">
<option value="1">Never</option>
<option value="5">Sometimes</option>
<option value="10">Over 3 times a week</option> <br>
Would you rather go to the ARC or CRCE?:
<select name= "Gym">
<option value="10">Arc</option>
<option value="1">CRCE</option>
<br>
How do you plan on eating most of your meals?:
<select name= "Gym">
<option value="5">Ordering delivery</option>
<option value="8">Walking To Green St.</option>
<option value="5">Making my own food</option>
<br>
Private or Public dorm?:
<select name= "Gym">
<option value="10">Private</option>
<option value="5">Public</option>
<br>
<input type="submit" value="get my results!">
</form>
</body>
</html>
You need to close your select tags (using </select>) after the option lists:
<select name= "Gym">
<option value="10">Arc</option>
<option value="1">CRCE</option>
</select>
Do that to every list.
You aren't closing your select tags. So the browser is trying to guess what you are trying to accomplish. Remember that all tags should be closed.
<select name= "Quad">
<option value="1">Not important</option>
<option value="3">Kind of important</option>
<option value="6">Very Important</option>
<option value="3">Only thing that matters</option>
</select>
For help finding these sorts of issues, run your page against an html validator.