I am new to perl and i have a button that when a user pressed that button, the value in the configuration file will be set to default.
Here is my configuration file named config.conf :
[status]
status.state=1
status.state2=0
status.state3=1
I want the configuration above to be set as default value means that the value that is 1 or 0 will be as default value. When a user change the value, for example :
[status]
status.state=1
status.state2=1
status.state3=0
And the user pressed the default button, the value in the configuration file will be the same as shown in the first one. How can i do this? What function do i need to use?
Here is my code for the interface :
#!/usr/bin/perl
#index.cgi
require 'foobar-lib.pl';
ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);
ui_print_footer("/", $text{'index'});
print "Content-type:text/html\n\n";
print qq~<html>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div id="content">
<div id="bar">
<span><p>Voice</p></span>
</div>
<div id="main-container">
<table width="100%" height="100%">
<tr>
<td width="30%" align="left">
<div id="title"><span>BYPASS :</span></div>
</td>
<td width="35%">
<div id="form">
<form method="POST" action="index2.cgi">
<select name="vdgpb" size="1">
<option value="bypass_a">VOC_BYPASS_A</option>
<option value="bypass_b">VOC_BYPASS_B</option>
<option value="bypass_c">VOC_BYPASS_C</option>
<option value="bypass_d">VOC_BYPASS_D</option>
</select>
</td>
<td align="left">
<input type="radio" name="pb" value="1">High (1)
</br>
<input type="radio" name="pb" value="0">Low (0)
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td wiidth="30%" align="left">
<div id="title"><span>SELECTION A :</span></div>
</td>
<div id="form">
<form method="POST" action="index3.cgi">
<td width="35%">
<select name="vdgph" size="1">
<option value="sel_a">SEL A</option>
<option value="sel_b">SEL B</option>
<option value="sel_c">SEL C</option>
<option value="sel_d">SEL D</option>
</select>
</td>
<td align="left">
<input type="radio" name="ph" value="1">High (1)
</br>
<input type="radio" name="ph" value="0">Low (0)
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td width="30%" align="left">
<div id="title"><span>IMPEDENCE</span></p>
<p><span>SELECTION :</span></p>
</div>
</td>
<div id="form">
<form method="POST" action="index4.cgi">
<td width="35%">
<select name="vdgpk" size="1">
<option value="z1_a">Z1_A</option>
<option value="z1_b">Z1_B</option>
<option value="z1_c">Z1_C</option>
<option value="z1_d">Z1_D</option>
<option value="z2_a">Z2_A</option>
<option value="z2_b">Z2_B</option>
<option value="z2_c">Z2_C</option>
<option value="z2_d">Z2_D</option>
</select>
</td>
<td align="left">
<input type="radio" name="pk" value="1">High (1)
</br>
<input type="radio" name="pk" value="0">Low (0)
</div>
</td>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<form action="index5.cgi"
<input type="submit" value="Default Settings">
</form>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
~;
Your CGI output is hendered as HTML in the browser so it is easiest to use an HTML component to do it for you. A reset button will do the trick.
Related
I have a in item list in each row has an edit button, which is supposed to open a partial view with the elements data to edit.
In the loop I use to fill tge datatable, I also create the partial views for each row element.
When I click the buton it always opens the first element partial view, even if I press the Nth element.
How do I get the code to open the corresponding partial view?
Code:
<table class="table table-hover" id="tabela_rota">
<thead>
<tr>
<th>
</th>
<th>
Cliente
</th>
<th>
Rota
</th>
<th>
Distância Ideal
</th>
<th>
Ativa
</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<partial>
#{await Html.RenderPartialAsync("Edit", item);}
</partial>
<tr>
<td width="15">
</td>
<td width="15%">
#Html.DisplayFor(modelItem => item.id_cliente)
</td>
<td width="25%">
#Html.DisplayFor(modelItem => item.nome)
</td>
<td width="15%">
#Html.DisplayFor(modelItem => item.distancia_ideal)
</td>
<td width="10%">
#Html.DisplayFor(modelItem => item.activa)
</td>
<td>
<button type="button" class="btn btn-outline-primary" onclick="openNavEdit()">
Editar
</button>
<button type="button" class="btn btn-outline-danger">Delete</button>
</td>
</tr>
}
</tbody>
</table>
JS Function:
function openNavEdit() {
document.getElementById("mySidepanelEdit").style.width = "350px";
}
View:
#model GestaoCircuitos.Models.Rota
#{
ViewData["Title"] = "Editar";
}
<div id="mySidepanelEdit" class="sidepanel">
<div id="top_title">
<h6 id="nova_rota">Editar Rota</h6>
<button class="closebtn" onclick="closeNavEdit()">×</button>
</div>
<div class="row form-row-rotas">
<div class="col-12">
<form asp-action="Edit" class="form-rotas">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="id" />
<div class="form-label-group">
<input id="nome" class="form-control" placeholder="Nome" />
<label asp-for="nome" class="control-label">Nome</label>
<span asp-validation-for="nome" class="text-danger"></span>
</div>
<div class="form-label-group">
<input type="text" asp-for="distancia_ideal" class="form-control" placeholder="Distância ideal" />
<label asp-for="distancia_ideal" class="control-label">Distância ideal</label>
<span asp-validation-for="distancia_ideal" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="activa" /> Ativa
</label>
</div>
<div class="form-group">
<input type="submit" value="Editar" class="btn btn-primary" />
</div>
</form>
</div>
</div>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
It's because you're opening based on ID. An ID attribute needs to be unique throughout a document. If you select on an ID, you'll only get the first element.
You'll have to give each edit modal either a unique ID or a class to select from. Try this:
#model GestaoCircuitos.Models.Rota
#{
ViewData["Title"] = "Editar";
}
<div id="sidepanel-edit-#(item.id)" class=" sidepanel">
<div id="top_title">
<h6 id="nova_rota">Editar Rota</h6>
<button class="closebtn" onclick="closeNavEdit(#(item.id))">×</button>
</div>
<div class="row form-row-rotas">
<div class="col-12">
<form asp-action="Edit" class="form-rotas">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="id" />
<div class="form-label-group">
<input id="nome" class="form-control" placeholder="Nome" />
<label asp-for="nome" class="control-label">Nome</label>
<span asp-validation-for="nome" class="text-danger"></span>
</div>
<div class="form-label-group">
<input type="text" asp-for="distancia_ideal" class="form-control" placeholder="Distância ideal" />
<label asp-for="distancia_ideal" class="control-label">Distância ideal</label>
<span asp-validation-for="distancia_ideal" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="activa" /> Ativa
</label>
</div>
<div class="form-group">
<input type="submit" value="Editar" class="btn btn-primary" />
</div>
</form>
</div>
</div>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
Above, we add a unique id for each edit edit form. Then we can reference those unique id attributes in the main template:
<table class="table table-hover" id="tabela_rota">
<thead>
<tr>
<th>
</th>
<th>
Cliente
</th>
<th>
Rota
</th>
<th>
Distância Ideal
</th>
<th>
Ativa
</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<partial>
#{await Html.RenderPartialAsync("Edit", item);}
</partial>
<tr>
<td width="15">
</td>
<td width="15%">
#Html.DisplayFor(modelItem => item.id_cliente)
</td>
<td width="25%">
#Html.DisplayFor(modelItem => item.nome)
</td>
<td width="15%">
#Html.DisplayFor(modelItem => item.distancia_ideal)
</td>
<td width="10%">
#Html.DisplayFor(modelItem => item.activa)
</td>
<td>
<button type="button" class="btn btn-outline-primary" onclick="openNavEdit(#(item.id)">
Editar
</button>
<button type="button" class="btn btn-outline-danger">Delete</button>
</td>
</tr>
}
</tbody>
</table>
and your Javascript would look like:
function openNavEdit(id) {
document.getElementById("sidepanel-edit-" + id).style.width = "350px";
}
function closeNavEdit(id) {
document.getElementById("sidepanel-edit-" + id).style.width = "0";
}
Something to note, I'm assuming your model has an id attribute.
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')
I have a list of buttons on a web page. I am able to get the list of buttons by using the Get Class Name function. But I am not able to iterate over it.
Here is the code:
main role="main">
<div class="wrapper">
</div>
<div class="wrapper wrapper-medium">
<header>
<h1>Unsubmitted Timesheets</h1>
<div class="clearfix">
<div class="fl-left">
<select name="" id="select-timeframe" class="hui-input"><option value="/missing_time/period/36/2018">05 Feb 2018 - 11 Feb 2018</option>
<option selected="selected" value="/missing_time/period/29/2018">This Week</option>
<option value="/missing_time/period/22/2018">22 Jan 2018 - 28 Jan 2018</option>
<option value="/missing_time/period/15/2018">15 Jan 2018 - 21 Jan 2018</option>
<option value="/missing_time/period/8/2018">08 Jan 2018 - 14 Jan 2018</option>
<option value="/missing_time/period/29/2018?all_weeks=1">- show all weeks -</option></select>
</div>
<div class="fl-right">
<button type="button" class="hui-button" data-open-dialog="email-reminder-dialog">
<i data-icon="check-green"></i>
Sending Reminder Every Friday
</button>
</div>
</div>
</header>
<section>
<form id="missing-time-form" action="/missing_time/reminders?return_to=%2Fmissing_time%2Fperiod%2F29%2F2018" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="?"><input type="hidden" name="authenticity_token" value="YmA26BT5bHy1NQKiKks+j/nKl5saFnF2fAmp/Oy6zuWANPkuuMLYTZDtdZHa/7TNh2CcUx5R2e0FsPWOxThVoQ==">
<table id="unsubmitted-timesheets" class="table">
<thead>
<tr>
<th></th>
<th>
Team Members<br>
<small>
Select:
<button type="button" class="button-link js-toggle-all-users">All</button>
/
<button type="button" class="button-link js-toggle-no-users">None</button>
</small>
</th>
<th class="text-right">Time</th>
<th></th>
</tr>
</thead>
<tbody class="has-clickable-table-rows" data-required-checkboxes="You must select at least one recipient.">
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1964976]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Alexander Cubillos" type="checkbox" value="1" name="send_reminder[1964976]" id="send_reminder_1964976">
<label for="send_reminder_1964976"></label>
</div>
</td>
<td>
Alexander Cubillos
<span class="text-label">Contractor</span>
<label for="send_reminder_1964976" class="clickable-row-link"></label>
</td>
<td class="text-right">
24:00
<label for="send_reminder_1964976" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1964976">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1840318]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Allain Dollete" type="checkbox" value="1" name="send_reminder[1840318]" id="send_reminder_1840318">
<label for="send_reminder_1840318"></label>
</div>
</td>
<td>
Allain Dollete
<label for="send_reminder_1840318" class="clickable-row-link"></label>
</td>
<td class="text-right">
24:30
<label for="send_reminder_1840318" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1840318">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1882520]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Anil Khemchandani" type="checkbox" value="1" name="send_reminder[1882520]" id="send_reminder_1882520">
<label for="send_reminder_1882520"></label>
</div>
</td>
<td>
Anil Khemchandani
<span class="text-label">Contractor</span>
<label for="send_reminder_1882520" class="clickable-row-link"></label>
</td>
<td class="text-right">
0:00
<label for="send_reminder_1882520" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1882520">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1028098]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Anna Jhaveri" type="checkbox" value="1" name="send_reminder[1028098]" id="send_reminder_1028098">
<label for="send_reminder_1028098"></label>
</div>
</td>
<td>
Anna Jhaveri
<label for="send_reminder_1028098" class="clickable-row-link"></label>
</td>
<td class="text-right">
0:00
<label for="send_reminder_1028098" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1028098">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1399194]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Chaitanya Potluri" type="checkbox" value="1" name="send_reminder[1399194]" id="send_reminder_1399194">
<label for="send_reminder_1399194"></label>
</div>
</td>
<td>
Chaitanya Potluri
<span class="text-label">Contractor</span>
<label for="send_reminder_1399194" class="clickable-row-link"></label>
</td>
<td class="text-right">
40:00
<label for="send_reminder_1399194" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1399194">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1908612]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Daniel Pedraza Mena" type="checkbox" value="1" name="send_reminder[1908612]" id="send_reminder_1908612">
<label for="send_reminder_1908612"></label>
</div>
</td>
<td>
I would Ideally like to click on a button got to the next page perform some action and then go back to the First Page. And then goto the next button. This action should be repeated until all the buttons are visited. I have been wracking my head around it but I have not able to come up with a solution.
I tried doing this, but it only targets the first or last button
($ie.Document.GetElementsByClassName("hui-button hui-button-tiny") |
Select-Object -First 1).Click()
($ie.Document.GetElementsByClassName("hui-button hui-button-tiny") |
Select-Object -Last 1).Click()
If I do something like this-
$ViewTimessheetObject=($ie.document.getElementsByClassName("hui-button hui-button-tiny") |Select-Object -first 1)
while($ie.Busy) { Start-Sleep -Milliseconds 100 }
($ViewTimesheetObject | ForEach-Object {$_.Click()})
It throws an error message saying that "You cannot call a method on a null-valued expression. + ($ViewTimesheetObject | ForEach-Object {$_.Click()})
Any help on this matter would be greatly appreciated.
your foreach should be for $ie.document.getElementsByClassName
($ie.document.getElementsByClassName("hui-button hui-button-tiny")) | Foreach { $_.Click()}
Let's say I have rendered the output rom the get request on an html template, now I need to use this same data to pass to a post request via a button on a same page. How do I do that?
I'm trying to do something like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Customer Home</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div th:replace="fragments/header :: header">
</div>
<div class="container">
<p> Thanks for booking with Gamma Airlines, here are your booking summary: </p>
<table th:object="${booking} class="table table-bordered table-striped">
<tbody>
<tr>
<td>Source</td>
<td th:text="${routeStart}"></td>
</tr>
<tr>
<td>Destination</td>
<td th:text="${routeDestination}"></td>
</tr>
<tr>
<td>Booking Charges</td>
<td th:text="${bookingCharges}"></td>
</tr>
<tr>
<td>Booking Charges Currency</td>
<td th:text="${chargesCurrency}"></td>
</tr>
<tr>
<td>Booking Date</td>
<td th:text="${#calendars.format(bookingDate)}">July 11, 2012 2:17:16 PM CDT</td>
<tr>
<td>
<div class="col-sm-9">
<form action="#" th:action="#{/email}"
th:object="${booking}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Email</button>
</form>
</div>
</td>
<td>
<div class="col-sm-9">
<form action="#" th:action="#{/genpdf}"
th:object="${booking}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Generate PDF</button>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Edit: Somebody please help tell me a simple method to pass the object since I have to use it at many places and object contains many child object as well in some cases. eg. the following case:
<div style = "margin-top: 2cm" class="container">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${offer}" method="post"
role="form">
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
UPDATE 2:
I even changed the template by sending a new object in the get request and try to assign values one by one but I still get it as null in a controller.
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${booking}" method="post"
role="form">
<input type="hidden" th:attr="value = ${offer.route.from}" th:field="*{routeStart}" />
<input type="hidden" th:attr="value = ${offer.route.to}" th:field="*{routeDestination}" />
<input type="hidden" th:attr="value = ${offer.price.amount}" th:field="*{bookingCharges}" />
<input type="hidden" th:attr="value = ${offer.price.currency}" th:field="*{chargesCurrency}" />
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
</table>
These are my get and post methods:
#RequestMapping(value="/user/booking", method = RequestMethod.GET)
public ModelAndView getOffers()
{
ModelAndView modelAndView = new ModelAndView();
AirlineOffer[] offersArray= airlineClient.getOffers();
List<AirlineOffer> offers = Arrays.asList(offersArray);
modelAndView.addObject("offers", offers);
Booking booking = new Booking();
modelAndView.addObject("booking", booking);
modelAndView.setViewName("user/booking");
return modelAndView;
}
/** POST method for submitting deposit request */
#RequestMapping(value = "/user/booking", method = RequestMethod.POST)
public ModelAndView book(#Valid Booking booking,
BindingResult bindingResult, HttpServletRequest request)
{
ModelAndView modelAndView = new ModelAndView();
......
}
Alright, I finally resolved it using the following in my form:
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>Source</td>
<td>Destination</td>
<td>Amount</td>
<td>Currency</td>
<td>Action</td>
</tr>
</thead>
<tbody>
<tr th:if="${offers.empty}">
<td colspan="5">No Offers</td>
</tr>
<tr th:each="offer, stat : ${offers}">
<td th:text="${offer.route.from}"></td>
<td th:text="${offer.route.to}"></td>
<td th:text="${offer.price.amount}"></td>
<td th:text="${offer.price.currency}"></td>
<td>
<form action="#" th:action="#{/user/booking}"
th:object="${booking}" method="post"
role="form">
<input type="hidden" th:value="${offer.route.from}" name="routeStart" />
<input type="hidden" th:value = "${offer.route.to}" name="routeDestination" />
<input type="hidden" th:value = "${offer.price.amount}" name="bookingCharges" />
<input type="hidden" th:value = "${offer.price.currency}" name="chargesCurrency" />
<button type="submit" class="btn btn-primary btn-block">Book</button>
</form>
</td>
</tr>
</tbody>
All it took was to remove th:field and add the name attribute.
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.