I am trying to get conditional display to work properly. What I am attempting to do is:
Within a block that has been merged, if a value is empty I want to display an input box along with a few other hidden variables I need to carry along with it, but if the value is not empty I wish to simply display that value.
PHP
$cks . . some query;
$TBS->LoadTemplate("check.html") ;
$TBS->MergeBlock("cks",$cks);
$TBS->Show(TBS_NOTHING); echo($TBS->Source);
Template portion
<td width="25%" class="mod_row2">[cks.check1]</td>
<td width="25%" class="mod_row2">
[cks.value;ifempty=
<input type="text" name="value[]" value="" size="26">
<input type=hidden name="check_id[]" value="[cks.check_id]">
<input type=hidden name="equip_id[]" value="[cks.equip_id]">
]</td> "
Everything works except the values of the hidden cells are not merged. I don't know if this is the right way to do this or if this is possible . . .
TBS 3.8.0, php 5.3.3
Thanks
Peter
Your HTML part with <input> is not parsed because it is embedded in a TBS parameter (ifempty).
It is not a good practice to embed HTML/XML in the TBS fields.
The best way is to use conditional display with block. The magnet feature is nice for that.
Example for you :
<td width="25%" class="mod_row2">[cks.check1]</td>
<td width="25%" class="mod_row2">
<div>
[cks.value;ope=mok:;magnet=div]
<input type="text" name="value[]" value="" size="26">
<input type=hidden name="check_id[]" value="[cks.check_id]">
<input type=hidden name="equip_id[]" value="[cks.equip_id]">
</div>
</td>
In this example, the parameter ope=mok: means that the block is displayed if the value is empty string (''), and is deleted in other cases.
Related
I am having issues with chromedp.Clear()
I am succesfully able to fill the below input with:
chromedp.SendKeys(`input[name="TESTFIELD"]`, "new value", chromedp.ByQuery)
But clearing it first with:
chromedp.Clear(`input[name="TESTFIELD"]`, chromedp.ByQuery)
A snippet of the HTML:
<input type="text" name="TESTFIELD" size="30" maxlength="30" value="" class="cssKenmerkNoLookup" valign="middle" onfocus=fnFieldChanged(this,1,0); onchange="fnSetDirty('cmdOK,cmdOKNext,cmdOKInvoeren,cmdStartMITOffice');" onkeydown="fnCheckForEdit('cmdOK,cmdOKNext,cmdOKInvoeren,cmdStartMITOffice', 'TESTFIELD',1);" onkeyup="fnCheckForEdit('cmdOK,cmdOKNext,cmdOKInvoeren,cmdStartMITOffice', 'TESTFIELD',0);" onpaste="fnCheckForEdit('cmdOK,cmdOKNext,cmdOKInvoeren,cmdStartMITOffice', 'TESTFIELD',0);" >
</td><td align="center" valign="middle" class="cssCellDetailsColLookup" nowrap >
I cant use the class, cssKenmerkNoLookup, since the same class is used with multiple inputs, so that is why I use "ByQuery"
What am I overlooking?
Issue solved.
by using:
chromedp.SetValue(selector, value, chromedp.ByQuery),
Current input value is replaced.
I have a form and I want to set default value in the field below but it's not working.
<span>ID User:</span>
<input type="text" th:value="${session.name}" th:field="*{userid}" th:errorclass="field-error" />
</div>
<div>
<span class="name-in">ID Room:</span>
<input type="text" th:value="${id}" th:field="*{room}" th:errorclass="field-error" />
</div>
I read some topic about this problem and I try to change as given below
th:attr="value = ${session.name}"
But It's still not working. Field ID User is empty. I don't know how to solve this problem.
Although your question contain less information, but i think you want to put default value for all field. If you like to do so change
`<input type="text" th:value="${session.name}" th:field="*{userid}" th:errorclass="field-error" />`
to
<input type="text" name="userid" value="as your wish" th:errorclass="field-error" />
Instead of changing the html, you should instead set the value of *{userid} in your controller. That way you can keep your html the same:
// Controller
modelObject.setUserId(session.name);
// HTML
<input type="text" th:field="*{userid}" th:errorclass="field-error" />
I have a list of similar looking DIVs without any Div ID, except one has a check box checked and others doesn't. What i need is to find the value from a child tag only if a radio button is selected.
Below is a simpler version of my code.
<div class = "XYZ">
<input type="radio" checked>
<input type="hidden" value="This is a great thing 1">
</div>
<div class = "XYZ">
<input type="radio">
<input type="hidden" value="This is a great thing 2">
</div>
Result needed is
This is a great thing 1
Unfortunately the source code cannot be changed.
Your xpath should look for a div that contains the checked input and to get the value for the one that has value attribute.
First selector returns the input, the second returns the value.
//div[.//input[#checked]]/input[#value]
//div[.//input[#checked]]/input/#value
As an alternative you can use the following sibling:
//input[#checked]/following-sibling::input
If you want to also use the class of the parent div:
//div[#class='XYZ']/input[#checked]/following-sibling::input
I have a <logic:iterate></logic:iterate> loop in which I added a checkbox I want that the checkbox should not be added after every element in <iterate> loop.
I only want to print my:
<input type="checkbox" id="configureCheckBox" >Configure<br/>
this checkbox with only first element.
Assuming that you are using an s:iterator tag (since the question is tagged as struts2), you can use the status attribute to check if you are printing the first element:
<s:iterator value="yourVar" status="cycleStatus">
<s:if test="#cycleStatus.first">
<input type="checkbox" id="configureCheckBox" >Configure<br/>
</s:if>
<%-- other code --%>
</s:iterator>
See also the s:iterator and IteratorStatus documentation.
You can play with indexId in this case.
You can use something like
<logic:iterate indexId="index">
<%if (Integer.parseInt(String.valueOf(index))){%>
<input type="checkbox" id="configureCheckBox" >Configure<br/>
<%}%>
</logic:iterate>
I've got a plain and simple HTML form which allows people to order some brochures. The form first loads with something looking a little like this:
<script type="text/javascript">
var tableRowN = 1;
</script>
<form id="Order" name="Order" method="post" action="includes/orderCheck.php">
<input id="name" type="text" name="name" width="100" />
<table id="orderingTable">
<tr class="lastRow">
<td><div id="itemGroupdiv1">
<input type="text" class="disabled" name="itemGroup1" id="itemGroup1" />
</div></td>
<td><div id="itemCodediv1">
<input type="text" name="itemCode1" id="itemCode1" class="disabled" />
</div></td>
<td><div id="itemCodeVersiondiv1">
<input type="text" class="disabledSmall" id="itemcodeversion1" name="itemcodeversion1" />
</div></td>
</tr>
</table>
<input type="submit" name="submit" id="submit"/>
</form>
Then when the user wants to add a new line to the table he can click a button which fires the following javascript function to grab the new table code via AJAX and insert it.
function createItemLine() {
tableRowN++;
$('tr.lastRow').attr('class', '');
$('#orderingTable').append('<tr class="lastRow"></tr>');
$.ajax({
url: "/orderingTable.php?rNumber=" + tableRowN,
cache: false,
success: function(html){
$("tr.lastRow").append(html);
alert('loaded');
}
});
}
The AJAX function then runs off to a PHP script which creates the next line, rolling the IDs and Names etc with +1 to the number.
<td><div id="itemGroupdiv2">
<input type="text" class="disabled" name="itemGroup2" id="itemGroup2" />
</div></td>
<td><div id="itemCodediv2">
<input type="text" name="itemCode2" id="itemCode2" class="disabled" />
</div></td>
<td><div id="itemCodeVersiondiv2">
<input type="text" class="disabledSmall" id="itemcodeversion2" name="itemcodeversion2" />
</div></td>
So so far, nothing suprising? Should all be pretty straight forward...
The problem is that when I add new lines (In Firefox and Chrome) the new lines are completely ignored by the form submission process, and they never get passed through into the $_POST array.
Is this a known problem? I've not come across this before...
Thanks for any pointers,
H
use jQuery.trim(data) but this is not pretty sure because can affect the
content of your data. or see this one may help u
Is your table missing an html id? The jQuery selector $('#orderingTable') is looking for something with id="orderingTable"
On some thorough (and boy do I mean thorough) it turned out that the following simple (yet obvious) HTML errors can cause this issue:
Badly formed code EG missing etc
Duplicate or missing form "name" attributes
On creating properly validated HTML, the form submitted and all values were passed correctly into the _POST array. An object lesson in making sure your developers pay attention to the basics before trying to get all fancy in their coding approach ;)
I've found that using .html() to insert the content instead of .append() or .prepend() causes the inserted form fields to work as expected.
I've just spent quite a while laboring over a problem like this.
I was ajax-ing an input field into a form and that input field was not showing up in the $_POST submission array, was completely annoying!!!! Aaaaanyway, I fixed it by just checking over all my html and it turns out that my form 'open' was inside one of the main div's on page and not outside.
thus:
<div>
<form>
<input type="text" name="input_field">
</div>
</form>
is now fixed to be:
<form>
<div>
<input type="text" name="input_field">
</div>
</form>
Silly, I know, but in a massive form, it was tricky to spot! So in short just be tidy with your html and it WILL work, I hope that helps someone somewhere :-)
M