Radio buttons instead of dropdown - forms

I have a problem, my client needs me to change a drop down menu to a radio button selection, 1 of them, needs to be endless options to be clicked, the other max of 4 out of 10.
This is what my form looks like:
<form id="contact-form" name="contact-form" method="post" action="submit.php">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="35%"><label for="name">Name</label></td>
<td width="52%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
<td width="13%" id="errOffset"> </td>
</tr>
<tr>
<td><label for="email">Email</label></td>
<td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
<td> </td>
</tr>
<tr>
<td><label for="subject">Area of Interest</label></td>
<td><select name="subject" id="subject">
<option value="" selected="selected"> - Choose -</option>
<option value="interactiveDinner">Interactive Dinner Series</option>
<option value="winemakerDinner">Winemaker Dinners</option>
<option value="Culinary Travel">Culinary Travel Adventures</option>
<option value="education">Food & Beverage Education</option>
<option value="host a Shikany Event">Host an event at your location</option>
<option value="partnership">Partner with us</option>
<option value="Hire Shikany">Hire Chef Michael Shikany for your event</option>
<option value="Charity Inquiry">Charity / Philanthrophy / Non-profit Inquiry</option>
</select> </td>
<td> </td>
</tr>
<tr>
<td valign="top"><label for="message">Please provide color to your inquiry</label></td>
<td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
<td valign="top"> </td>
</tr>
<tr>
<td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
<td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="Submit" />
<input type="reset" name="button2" id="button2" value="Reset" />
height="16" alt="loading" /></td>
</tr>
</table>
</form>
<?=$success?>
</div>

It sounds like you need to use check boxes instead of radio buttons. That will allow the user to select as many of the options as they want. To limit the number of selections they can make to 4, you can use the code found at http://www.javascriptkit.com/script/script2/checkboxlimit.shtml
Hope this helps.

You will not be able to achieve what you describe with radio buttons, you will need to use checkboxes. This is simply so more than one option can be selected.
Also if you name each checkbox in each group with the same name, something like select1[] and select2[]. Then when you post your form back to the server, the selected options will magically be in an array.
If you want to limit the number of selected boxes, then you will have to use some javascript that fires on the click event of each checkbox to count the number selected and allow or disallow any further selections.

Related

I have this code, when submited the form dont refresh, someone know how refresh after submit on october cms?

<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco' "
data-request-flash >
<table>
<tr>
<td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
</tr>
<tr>
<td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
</tr>
<tr>
<td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
</tr>
</table>
<button type="submit" >Enviar</button>
<input type="hidden" value="{{usuario.id}}" name="id">
this code work, saves the values on database, but i need manually refresh page to see the result on my
screen, someone know how refresh after submit?
Please, explain most simple possible, i am newbie
The best way to do what you want is to put the form in a partial and update it when the form is submitted.
Replace your form with this:
<div id="specialForm">
{% partial __SELF__~"::specialForm" %}
</div>
Create a partial to describe the form; I used specialForm. It should reload the form and clear the content.
<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco', '{{ __SELF__ }}::specialForm': '#specialForm' "
data-request-flash >
<table>
<tr>
<td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
</tr>
<tr>
<td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
</tr>
<tr>
<td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
</tr>
</table>
<button type="submit" >Enviar</button>
<input type="hidden" value="{{usuario.id}}" name="id">
</form>

Protractor expect specific text siblings of selector

I have a table like this:
<table>
<tbody>
...
<tr>
<td>
<div class="radio-inline">
<input name="sms_provider" type="radio" value="2" id="2">
<label class="text-gray-dark" for="2"> </label>
</div>
</td>
<td data-label="Server name">ServerA3</td>
<td data-label="Description"></td>
<td data-label="Status">
<label class="text-success">
<clr-icon shape="check"></clr-icon>
Default
</label>
</td>
<td data-label="Actions">
<a href="http://example.com/public/smsconfigurations/2/edit" data-tooltip="Edit Server">
<clr-icon shape="pencil" size="22" style="width: 22px; height: 22px;"></clr-icon>
</a>
</td>
</tr>
...
</tbody>
</table>
Now I wanna to check ServerA3 has Default status or no. As matter of fact I expect ServerA3 has Default text as siblings. What should I do?
I try with this code, but it doesn't work:
expect(element(by.xpath('//td[contains(text(), "ServerA3")]')).getWebElement().getDriver().findElement(by.css('*[data-label="status"]')).getText()).toContain('Default');
var status = element(by.xpath('//tr[td[.="ServerA3"]]/td[#data-label="Status"]'))
.getAttribute('innerText');
expect(status).toEqual('Default')

To Get Text From A Locater Using Selenium IDE

<br>
<br>
To add new COT click on "Add New COT"
<div class="stepandbutton">
<div class="globalbuttoncell">
<a class="buttonlink blockpage" onclick="javascript:addnewcot();" href="#">Add New COT</a>
</div>
</div>
<input id="ComingFromForm" type="hidden" value="ComingFromForm" name="ComingFromForm">
<input id="priorCOT" type="hidden" value="" name="priorCOT">
<input id="rtncode" type="hidden" value="false" name="rtncode">
<input id="refresh" type="hidden" value="NO" name="refresh">
<input id="PDate" type="hidden" value="" name="PDate">
<table>
<thead>
<tr>
<th align="center"> *Trade Class</th>
<th align="center">*Description</th>
<th>Category </th>
<th>Exclude from AMP</th>
<th>Exclude from AMP 5i</th>
<th>Exclude from ASP</th>
<th>Exclude from BP</th>
<th>Exclude from NFAMP </th>
<th>Exclude from Texas </th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">
<input id="COT" class="data" type="text" value="" style="width:100px;" name="COT">
</td>
<td align="center">
<input id="Desc" class="data" type="text" value="" style="width:250px;" name="Desc">
</td>
<td align="center">
<select id="COTCategory" class="data small" name="COTCategory">
</td>
<td align="center">
<td align="center">
<td align="center">
<td align="center">
<td align="center">
<td align="center">
</tr>
</tbody>
</table>
</form>
<br>
<br>
I need to verify only ""To add new COT click on "Add New COT""" which is in the 3rd line is present.I have tried with //br[contains(text(),"To add new COT click on "Add New COT"")]. But it showing error that locator is not found.Please suggest another ways to verify it.
This is ugly but would "work":
<tr>
<td>verifyText</td>
<td>//body</td>
<td>*To add new COT click on "Add New COT"*</td>
</tr>
But as the commenter above mentions you don't want the br element. What you want to locate on is the element that you didn't provide that lives ABOVE the code you attached to. That would be best.

Form has Disabled Inputs, How to make Processing Page not try to process disabled fields?

I have a form where I disable the Shipping address when they click the "Same as Billing address" checkbox via JQuery.
When the form is submitted, the disabled fields (shipping) obviously do not pass any data but my processing form is saying that those specific fields are undefined.
How can I make the processing form not look for the values of the disabled fields (shipping), if they are disabled?
HERE IS THE PROCESSING FORM:
<cfset orderno = #numberFormat(randrange(00001,99999), "00000")#>
<cfmail to="xxx" from="xxx" subject="xxxx ORDER No. #orderno#" server="xxx" username="xx" password="xxx" type="html">
<img src="http://www.mmprint.com/index_files/maillogo.jpg" width="500" height="85" /> <br /><br /> <font face="Arial" size="+3"><strong>NEW LIVE JOB - <font color="##FF0000">CMS-1500 BLANK </font> Form Order No. <cfoutput>#orderno#</cfoutput> </strong>
<table border="1" bordercolor="##660000" cellpadding="2" cellspacing="0">
<tr>
<td colspan="2"><h2>CMS-1500 Order Information:</h2></td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Quantity:</td><td align="left" valign="top">#form.qty#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Type:</td><td align="left" valign="top">#form.cctype#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">CC Number:</td><td align="left" valign="top">#form.ccnumber#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">CC Month:</td><td align="left" valign="top">#form.ccmonth#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">CC Year:</td><td align="left" valign="top">#form.ccyear#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">CSV:</td><td align="left" valign="top">#form.csv#</td>
</tr>
<!-- Billing Info -->
<tr>
<td><h2>Billing Information:</h2></td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Company Name:</td><td align="left" valign="top">#form.bconame#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">First Name:</td><td align="left" valign="top">#form.bfname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Last Name:</td><td align="left" valign="top">#form.blname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.baddress#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.baddress2#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.bcity#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.bstate#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.bzip#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Email:</td><td align="left" valign="top">#form.email#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Comments:</td><td align="left" valign="top">#form.comments#</td>
</tr>
</table>
<br />
<br />
<!-- SHIPPING INFO -->
<table border="1" bordercolor="##660000" cellpadding="2" cellspacing="0">
<tr>
<td><h2>Shipping Information:</h2></td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Company Name:</td><td align="left" valign="top">#form.coname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">First Name:</td><td align="left" valign="top">#form.fname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Last Name:</td><td align="left" valign="top">#form.lname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.address#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address 2:</td><td align="left" valign="top">#form.address2#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">City:</td><td align="left" valign="top">#form.city#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">State:</td><td align="left" valign="top">#form.state#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Zip:</td><td align="left" valign="top">#form.zip#</td>
</tr>
</table>
</font>
</cfmail>
<cfmail to="#form.email#" from="xxx" bcc="xxx" subject="Thank You for your order - No. #orderno#" server="xxx" username="xxx" password="xxx" type="html">
<p><img src="xxx" width="500" height="85" /></p>
<p><font face="Arial" size="+1"><strong><font color="##006600">Order Confirmation- </font>- No. <cfoutput>#orderno#</cfoutput> </strong>
</font></p>
<font face="Arial" size="1"><p>Your order for <cfoutput>#qty#</cfoutput>xxx has been successfully received.</p>
<p>If your order is received by 2PM (ET) they will ship the same day!</p>
<p>Questions or Comments? Please call us at 1-877-mmprint or 516-334-1603 or email info#mmprint.com </p></font>
<table border="1" bordercolor="##660000" cellpadding="2" cellspacing="0">
<tr>
<td><h2>Shipping Information:</h2></td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Company Name:</td><td align="left" valign="top">#form.coname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">First Name:</td><td align="left" valign="top">#form.fname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Last Name:</td><td align="left" valign="top">#form.lname#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address:</td><td align="left" valign="top">#form.address#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Address 2:</td><td align="left" valign="top">#form.address2#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">City:</td><td align="left" valign="top">#form.city#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">State:</td><td align="left" valign="top">#form.state#</td>
</tr>
<tr>
<td bgcolor="##CCCCCC" align="left" valign="top">Zip:</td><td align="left" valign="top">#form.zip#</td>
</tr>
</table>
</cfmail>
<cflocation url="thanks.cfm?name=#form.bfname#" addtoken="no">
HERE IS THE FORM ITSELF:
<form action="process.cfm" id="blank-form" method="post" class="vertical">
<div class="col_4 ">
<fieldset>
<legend>Choose Your Quantity:</legend>
<p>
<select id="qty" name="qty" size="4" data-validation="required" data-validation-error-msg="Please Select a Quantity." >
<option value="100 Blank">100 - Blank CMS 1500 </option>
<option value="250 Blank">250 - Blank CMS 1500 </option>
<option value="500 Blank ">500 - Blank CMS 1500 </option>
<option value="1000 Blank">1000 - Blank CMS 1500 </option>
</select>
</p> <div style="font-size:0.7em; text-align:right;">*plus shipping and handling</div>
</fieldset>
<!-- CREDIT CARD -->
<fieldset>
<legend><i class="icon-lock"></i> Payment Information </legend>
<label for="cctype">Type</label>
<select id="cctype" name="cctype" data-validation="required">
<option value="VISA">VISA</option>
<option value="MC">Mastercard</option>
<option value="AMEX">AMEX</option>
<option value="DISC">Discover</option>
</select>
<label for="ccnumber">Credit Card Number</label>
<input type="text" id="ccnumber" name="ccnumber" data-validation="number" data-validation-error-msg="Please Enter a Valid Credit Card Number." >
<div class="col_5"> <label for="ccmonth">Expiration</label>
<select name="ccmonth" id="ccmonth" data-validation="required">
<option value = "1">January</option>
<option value = "2">February</option>
<option value = "3">March</option>
<option value = "4">April</option>
<option value = "5">May</option>
<option value = "6">June</option>
<option value = "7">July</option>
<option value = "8">August</option>
<option value = "9">September</option>
<option value = "10">October</option>
<option value = "11">November</option>
<option value = "12">December</option>
</select></div>
<div class="col_4"> <label for="ccyear">Year</label>
<select name="ccyear" id="ccyear" data-validation="required">
<option value = "2014" >2014</option>
<option value = "2015">2015</option>
<option value = "2016">2016</option>
<option value = "2017">2017</option>
<option value = "2018">2018</option>
<option value = "2019">2019</option>
<option value = "2020">2020</option>
</select></div>
<div class="col_3"><label for="csv" >CSV #</label>
<input type="text" name="csv" id="csv" data-validation="required" data-validation-error-msg=" "></div>
</fieldset>
<fieldset><legend>Email & Phone</legend>
<input type="text" placeholder="your#email.com" name="email" id="email" data-validation="email" data-validation-error-msg="Please enter a valid email where you can receive your order confirmation.">
<input type="text" placeholder="555-505-5050" name="phone" id="phone" data-validation="number" data-validation-error-msg="Please enter a phone number where we can contact you."></fieldset>
</div>
<div class="col_4">
<fieldset>
<legend>Billing Information</legend>
<p><input type="checkbox" id="sameasbilling"> Ship to Same As Billing Address</p>
<label for="bconame">Company Name</label>
<input type="text" id="bconame" name="bconame" minlength="2"/>
<label for="bfname">First Name</label>
<input type="text" id="bfname" name="bfname" minlength="2" data-validation="required"/>
<label for="blname">Last Name</label>
<input type="text" id="blname" name="blname" minlength="2" data-validation="required"/>
<label for="baddress">Address</label>
<input type="text" id="baddress" name="baddress" minlength="2" data-validation="required"/>
<label for="baddress2">Suite/Apt #</label>
<input type="text" id="baddress2" name="baddress2" />
<label for="bcity">City</label>
<input type="text" id="bcity" name="bcity" data-validation="required" />
<label for="bstate">State</label>
<input type="text" id="bstate" name="bstate" minlength="2" data-validation="required" />
<label for="bzip">Zip</label>
<input type="text" id="bzip" name="bzip" minlength="5" data-validation="required"/>
</fieldset>
</div>
<div class="col_4" id="shipping">
<fieldset>
<legend>Shipping Information</legend><br><br>
<label for="coname">Company Name</label>
<input type="text" id="coname" name="coname" minlength="2" />
<label for="fname">First Name</label>
<input type="text" id="fname" name="fname" minlength="2" data-validation="required"/>
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lname" minlength="2" data-validation="required" />
<label for="address">Address</label>
<input type="text" id="address" name="address" minlength="2" data-validation="required"/>
<label for="address2">Suite/Apt #</label>
<input type="text" id="address2" name="address2" />
<label for="city">City</label>
<input type="text" id="city" name="city" data-validation="required"/>
<label for="state">State</label>
<input type="text" id="state" name="state" minlength="2" data-validation="required"/>
<label for="zip">Zip</label>
<input type="text" id="zip" name="zip" minlength="5" data-validation="required" />
</fieldset>
</div>
<div class="row">
<fieldset>
<legend>Comments | Special Instructions</legend>
<textarea id="comments" name="comments"></textarea>
<div class="right">
<button class="pop orange">Send the order!</button></div>
</form>
THE JQUERY:
<script>
$(document).ready(function() {
$('#sameasbilling').change(function(){
if ($('#sameasbilling').is(':checked')){
$('#shipping :input').addClass('disabled').prop('disabled', true).attr("value","Same As Billing");
} else {
$('#shipping :input').removeClass('disabled').prop('disabled', false).removeAttr("value");
}
});
$.validate();
})
</script>
I figured out that I can simply use
<cfparam name="form.name" default = "Default text">
to replace the missing fields when the form is processed.
I only accept this solution because my form is short. I'm sure there is a better way to do this for bigger forms that handle lots of data.
Hope this will help someone else.

Is my form laid out in a table accessible?

I am making a form to search for colleges based on athletic programs offered and the division of the sport. I have laid the form out in a table. The "all divisions" checkbox selects all the checkboxes for that sport.
I know screen readers have both forms and tables mode. Is my current design accessible or should I add labels for each individual checkbox and position them off-screen for visual users? This also needs to meet at least Section 508 requirements.
Current code for the tables looks like this:
<table>
<tr><th scope="col" colspan="2">All Divisions</th>
<th scope="col">Div I</th>
<th scope="col">Div II</th>
<th scope="col">Div III</th>
<th scope="col">Other</th>
</tr>
<tr><th scope="row">Baseball</th>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
</tr>
<tr><th scope="row">Basketball</th>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
</tr>
</table>
What I want to know is whether or not a screen reader is able to associate the table headings with the checkboxes.
It is accessible. I coppyed the code into a html document and was able to read the check boxes with headers in both firefox 3.0 and Internet explorer 7 using Jaws version 10.0 as the screen reader.
I think you're going to need individual labels for each of the checkboxes, but you may be able to use the headers attribute on the table cells to accomplish the same effect.
Ok using the "ID" and "Headers" attributes in tables (scroll down to section).
<table>
<tr><th id="all" colspan="2">All Divisions</th>
<th id="div1">Div I</th>
<th id="div2">Div II</th>
<th id="div3">Div III</th>
<th id="other">Other</th>
</tr>
<tr><td id="baseball">Baseball</td>
<td headers="baseball all"><input type="checkbox" /></td>
<td headers="baseball div1"><input type="checkbox" /></td>
<td headers="baseball div2"><input type="checkbox" /></td>
<td headers="baseball div3"><input type="checkbox" /></td>
<td headers="baseball other"><input type="checkbox" /></td>
</tr>
</table>