Two forms where the second reads the first form - forms

I have two nearly identical forms on a page with two buttons, one for each form.
Now I want the second button to also read data from the fields of the first form and hide the fields of the second form or not have them. How can I do that?
the first form
<form:form id="excelform" commandName="tg35FormBackingModel" action="${createExcel}" method="post">
<div>
<table>
<tr>
<td class="tg35-left"><spring:message code="tg35.fromDate" />
<em title="<spring:message code='tooltip.mandatory' />"
class="mandatory float-right">*</em>
</td>
<td><form:input path="fromDate" cssClass="dateInput" /> <form:errors
cssClass="ui-state-error ui-corner-all" path="fromDate" />
</td>
</tr>
...

Related

Issue finding elements using Selenium::Remote::Driver in Perl

As part of a test scrip I have to redirect to a 3rd party hosted payment page. However, when I try and find the input box elements it errors slightly differently depending on which call I try:
$driver->find_element_by_id("card.billingAddress.houseNumberOrName")->clear
returns "Element is not currently visible and so may not be interacted with"
$driver->find_element_by_xpath('//input[#id="card.billingAddress.houseNumberOrName"')->clear
returns "SyntaxError: The expression is not a legal expression."
The source of the section I am searching is:
<tr>
<td colspan="2"><div class="fieldSubHeader">Billing Address</div>
</td>
</tr>
<tr>
<td><div id="idAddress1_card" style="display:inline">Address 1</div>
<div id="idHouseNumberOrName_card" style="display:none">House Number/Name
</div</td>
<td><div class="fieldDiv" id="idDivAddress1_card">
<input type="text" class="inputField" id="card.billingAddress.houseNumberOrName" name="card.billingAddress.houseNumberOrName" value="" size="15" maxlength="40" />
</div></td>
</tr>
Is it the . in the ID that is causing the issue?
(I have checked the computed CSS and it is not hidden!)
Many thanks
You are missing the closing ]. Replace:
'//input[#id="card.billingAddress.houseNumberOrName"'
with:
'//input[#id="card.billingAddress.houseNumberOrName"]'
HERE ^
Note that you might simplify it by switching directly to the find_element_by_id() method.

MailChimp custom template problems with drag and drop blocks

I am creating a custom MailChimp template but having issues when using the mc:repeatable element. I have it on a wrapped around a block of code and in the editor when creating a campaign, it works fine, I can spawn a new version of the parent block and move it around in the template, but when I preview, or send the email, the child block that was spawned from the parent sits below it's parent and not where I have placed it following spawning it from the parent block... Something seems to be wrong? (Heavily simplified) Code example below... Anyone any ideas on the fix???
<!-- BLOCK A -->
<div style="width:100%" mc:repeatable="CONTENTBLOCK_A">
<p>This is block A</p>
</div>
<!-- end of BLOCK A -->
<!-- BLOCK B -->
<div style="width:100%" mc:repeatable="CONTENTBLOCK_B">
<p>This is block B</p>
</div>
<!-- end of BLOCK B -->
So, when creating a new campaign, if I duplicate BLOCK A and position the duplicated BLOCK A below BLOCK B - in the preview within the campaign editor it looks fine, but when I click to view it into PREVIEW MODE, or send a PREVIEW EMAIL - the duplicated BLOCK A sits above BLOCK B and below its original spawned parent BLOCK A element...
Any ideas? Are the HTML COMMENTS (e.g. < !-- --> ) The issue perhaps?
Very late, but I was able to find success using this:
<table mc:repeatable="content" mc:variant="variant_1">
<tr>
<td mc:edit="section_1">
Variant 1 Content
</td>
</tr>
</table>
<table mc:repeatable="content" mc:variant="variant_2">
<tr>
<td mc:edit="section_2">
Variant 2 Content
</td>
</tr>
</table>
<table mc:repeatable="content" mc:variant="variant_3">
<tr>
<td mc:edit="section_3">
Variant 3 Content
</td>
</tr>
</table>
More in depth explanation can be found here: Create Editable Content Areas with MailChimp’s Template Language

How to auto fill form fills based on data from a table?

I have a form which the data is being submitted to a table.
Using the column 'month_date_show' I would like to auto fill the form
if that date exist in the column in the table, since it will only be submit once a month.
If the date does exist in the table then the user will be able to edit those results, if it does not exist
then no need to auto fill the user will submit new results for that month.
Not sure if this is something that will have to use ajax or java script to make it happen.
Right now I hard coded the values in the form , but i would like to make it dynamic.
<cfquery datasource ="intranet" name="GetSummary">
SELECT * from cse_result_summary
</cfquery>
<form method="post" name="myform" action="cse_execoffice_datepicker_test.cfm" onsubmit="return validateForm()">
<table >
<tr>
<td>
<input type="text" id="dpMonthYear" NAME="month_date_show" value="9/2014" style="width:80px;" />
</td>
<td>
<img alt="Month/Year Picker" onclick="showCalendarControl('dpMonthYear');"
src="pictures/datepicker.gif" />
</td>
</tr>
</table>
<table >
<tbody>
<tr>
<td> Rising Star Award Winner:</td>
<td><input type="text" name="risingstar" size="50" class="get_branches_departments_displaynum" value="john"></td>
</tr>
<tr>
<td>Department Average:</td>
<td><input type="text" name="risingstar_ave" size="8" class="get_branches_departments_displaynum" value="5"></td>
</tr>
<tr>
<td> Rising Star Award Winner runner-up:</td>
<td><input type="text" name="risingstar_runner" size="50" class="get_branches_departments_displaynum" value="joe"></td>
</tr>
</tbody>
</table>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
Well, if you are actually storing the month and year of the forms submitted, and assuming that the users are submitting form for the current month and current year (i.e. it is September 2014 now and the users would be submitting form for 09/2014 but not submitting form for any other form, ex. 08/2014), then at the time when a user gets to your page, you already know whether a new form is needed by searching against the database.
You can then populate the form accordingly.
It depends. If you don't care if the user refreshes the page, just submit the form onChange, run the query to select information for that date
SELECT winner, average, runup
FROM tablename
WHERE datecol = <cfqueryparam type=<whatevertypeappropriate> value="#val_name#">
In your form just have the value field value dynamically assigned.
<input type="text" name="winner" value="#queryname.winner#">
If you don't want them to have to resubmit the form, I think there'll have to be some kind of binding.

HTML form interleaves with <div> or <td> won't work

Does anybody experience the odd phenomenon: if an HTML form is divided into several parts by <div>'s or table <td>'s, then the <input type="submit" ... > button won't work -- nothing happens when clicking (no 'post' message is sent). If I take out all the <div>'s or table elements, the button works. Why is that? In my case, the form is inserted by Ajax. Could that be a cause of the problem? Thanks.
For example:
<div style="float:left">
<form action="/..." class="submitForm" method="post">
...
...
</div>
<div style="float:left">
...
...
</div>
<div>
...
<input type="submit" value="submit">
</form>
</div>
or,
<table>
<tr>
<td>
<form action="/..." class="submitForm" method="post">
...
...
</td>
<td>
...
<input ...>
...
</td
<td>
...
<input type="submit" value="submit">
</form>
</td>
There is nothing odd about it.
The HTML is invalid. The code doesn't mean anything.
Then the browser attempts to recover from your error. The results are not what you want.
If you don't write real HTML, you shouldn't expect browsers to be able to handle it.
Elements must describe a tree. If you open an element, you must close it before you close any of its ancestors.
http://validator.w3.org/ provides a useful tool for performing basic automated QA on your HTML.

Make radio buttons mutually exclusive when not contained in the same form element?

I'm making a calendar where each day has a radio button that allows you to select it. I want users to only be able to select one day. The issue I'm having is I've made the calendar as a table so each <td> has the following:
<td>
<form>
Mon 18
<input type="radio" name="day" value="mon18" />
</form>
</td>
So as all the radio buttons aren't contained in one form element, the normal behaviour that makes the selection mutually exclusive isn't occurring. If I create 1 form element around all my mark up then the table will be contained in it, would this be semantically correct?
Is there a semantically correct solution to my problem? I guess I could do it with javascript and server side validation.
It is perfectly semantically correct to have the form enclosing your table, that's actually the only sensible way to build your radiobutton-based calendar with mutually exclusive selection!
The following code does validate:
<form>
<table>
<tr>
<td><input type="radio" name="day" value="1"></td>
<td><input type="radio" name="day" value="2"></td>
...
</tr>
</table>
</form>