I have a thymeleaf html template which has fragment like this, where in for each order I am passing some flag (showInvoice, isPremium).
<th:block th:each="order: ${restaurant.orders}">
<th:block
th:include="fragments/orderDetails:: order-Details(showInvoice='false', isPremium='true')"/>
<hr style="color: #c6c6c6; margin-top: 18px; margin-bottom: 24px;"/>
</th:block>
Then for each orderDetail I have another template which is being used in multiple places and hence the flags have true or false based on where they come from or may not have anything(null)
The child template for each order detail where I am retrieving the flag looks like this
<body th:fragment="order-Details"
th:with="showInvoice=${showInvoice} ?: 'false', isPremium=${isPremium} ?: 'false'"
style="margin-top: 24px;width:100%">
Now for whatever reason, the first variable is correctly parsed, but for the second one, I am not getting the value and is always null. I was wondering if I have done anything wrong here. I also tried the following and still its not working
<body th:fragment="order-Details"
th:with="showInvoice=${showInvoice} ? ${showInvoice} : 'false', isPremium=${isPremium} ?${isPremium}: 'false'"
style="margin-top: 24px;width:100%">
The idea here was to have the flag correctly set to true of false in case the parent template sends it or not
Related
i using simple_html_dom.php
how to get textarea value if the website has used bad tag.
the textarea tag already closed before </textarea> like input tag.
Textarea HTML like below:
<textarea name="xxx" id="xxx" />this is value</textarea>
When i use this function, i dont get anything
$textarea = $html->find("textarea[name=xxx]");
$contents = $textarea->innertext;
echo $contents;
how to get 'this is value' using simple_html_dom.php or other alternative?
Thank you
Well, my previous comment won't work in this case, I'll leave it for info though...
Another approach is to clean it up before parsing it with simple_html_dom using Tidy extension. But it seems not to be working here either...
A last approach I can think of, and if this is your only problematic case, is to use regex to get what you want:
Using <textarea.*?name="xxx".*?id="xxx".*?\/>([^<]+)<\/textarea> ==> RegEx DEMO
The output will be in group one of the resulting array $match. Check this working code:
$input = <<<_DATA_
<textarea name="xxx" id="xxx" />this is value</textarea>
_DATA_;
$pattern = '/<textarea.*?name="xxx".*?id="xxx".*?\/>([^<]+)<\/textarea>/';
preg_match($pattern, $input, $match);
var_dump($match)
Working DEMO
It is easy to get the value of a Teaxtarea in javascript:
<script type=text/javascript>
function getValueTextarea()
{
var vl=document.getElementById("tx").value;
alert(vl);
}
</script>
<body>
<textarea id="tx">Value Of Textarea</textarea>
<input id="button" value="Get Value" onclick="getValueTextarea()">
</body>
I have a textarea and for some reason when I try to add text in between the open and close brackets of my textarea it wont display, whether I use html content or php echoed content.
It works if I place the content in a place holder though, does anyone know why this is happening?
<form action="includes/changebio.php" method="post" id="form1">
<textarea id="bio" style="width: 440px;
margin-top:3px;
text-align:left;
margin-left:-2px;
height: 120px;
resize: none;
outline:none;
overflow:scroll;
border: #ccc 1px solid;"
textarea name="bio" data-id="bio"
maxlength="710"
placeholder="<?php echo stripslashes($profile['bio']); ?>" rows="10">
</textarea>
<input type="image" src="assets/img/icons/save-edit.png"
class="bio-submit" name="submit" value="submit" id="submit"/>
</form>
Try adding a name="textarea-name"attribute to the textarea (even if you have no use for it)
Edit:
I have tested a <textarea name="bio">textarea content</textarea> piece of code and concluded that (as strange as it may seem), if the textarea name is bio, the content is no shown in Firefox, although it is present if the element is inspected with Firebug or a similar tool.
It appears to be something caused by one of my add-ons, as the textarea content it is displayed correctly by other browsers and when using a clean new Firefox profile.
I have not investigated further though.
Simplest method that worked for me:
Instead of doing:-
<textarea name="scenario" value="<?php echo $scenario?>"> </textarea>
Do it like this:-
<textarea name="scenario"> <?php echo $scenario?> </textarea>
I have similar problem! When I change the content with ajax, Chrome & Firefox displayed nothing, but IE displayed correctly. What strange is the content is present if the element is inspected with Firebug or a similar tool.
You have extra textarea after style tag. Here is the code.
<form action="includes/changebio.php" method="post" id="form1">
<textarea id="bio" style="width: 440px;
margin-top:3px;
text-align:left;
margin-left:-2px;
height: 120px;
resize: none;
outline:none;
overflow:scroll;
border: #ccc 1px solid;" name="bio" data-id="bio" maxlength="710"
placeholder="<?php echo stripslashes($profile['bio']); ?>" rows="10"><?php echo stripslashes($profile['bio']); ?></textarea>
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/>
</form>
I also faced the similar problem and resolved it by doing like this:
{{\App\ArtObject::find($id)->description}}
Earlier I had:
description}}">
The later case did NOT show the value as expected.
If your problem is same as mine, where I placed a string variable with 1500 chars for a web content, between the two tags, and only partial appeared inside the Textarea on the page. Only about 900 chars displayed. A large part at the end were missing. Then, you may try what worked for me, where I used the htmlspecialchars() function like this:
<TEXTAREA><?php echo htmlspecialchars($pgCont); ?></TEXTAREA>
I still don't know why this function may be required to show the full contents of the string variable. Perhaps, for security reasons.
I currently have a link in the below form:
Change
In order to fit the look of the site in which I'm adding this link, I want to change it to a button input, as so:
<input type="button" value="Change" onclick="changeNumbers('Numbers', '#Url.Action("ChangeNumbers")')" />
However, I'm running into a snag with this second form: the single quotes around #Url.Action("ChangeNumbers") are being flagged as Unterminated string constant. Can anyone tell me what I'm doing incorrectly and how to fix it?
EDIT
It didn't occur to me to just try the page - it looks like the second form works. So now my question is - why is Visual Studio flagging this as incorrect?
You're not doing anything "incorrectly" per se, it's just that Razor isn't perfect, and things like quotes within quotes tend to cause it to freak.
One quick fix would be to store the URL in a variable and then use the variable:
#{ var url = Url.Action("ChangeNumbers"); }
<input type="button" value="Change" onclick="changeNumbers('Numbers', '#url')" />
However, an even better fix is to not use the onclick attribute at all. Put this where it belongs: in JS.
<script>
$('#myButton').on('click', function () {
changeNumbers('Numbers', '#Url.Action("ChangeNumbers")');
});
</script>
Used jQuery above, since it's included in MVC by default
I've found that to make Visual Studio happy in this scenario, the easiest thing to do is simply change the <input /> element to a <button></button> element and the error will resolve itself:
<button type="button" onclick="changeNumbers('Numbers', '#Url.Action("ChangeNumbers")')">Change</button>
Otherwise, to continue using an <input /> the markup will need to be changed to the following:
<input type="button" value="Change" onclick="#("changeNumbers('Numbers', '" + Url.Action("ChangeNumbers") + "')")" />
Basically I'm making a repeatable section and I want to have the checked state of all checkboxes pre-supplied by an array.
<div style="height: 100%; border: 1px solid grey; overflow-y: scroll;" id="AssociatedUsers" data-bind="foreach: AllUserList">
<input type='checkbox' class='cSupUser' style="width:20px;margin:2px" value="$data" data-bind='checked: supplierUsers' /><span data-bind='text: $data.Text'></span><br />
</div>
But obviously value="$data" is just returning the string "$data". I've decided to start working on a solution where I just map the array with json strings when I save and load the related data, but this adds complication and feels like a hack, so I was wondering if there is a better way to handle this situation. I would also prefer supplierUsers could just be mapped directly to the viewModel, because I'm going to be generating the response to the server from the viewModel, but it seems like observableArrays don't work for that parameter.
I'm only 3 days into using knockout framework, any help/suggestions are appreciated.
The way i've dealt with this is to use the attr binding for each checkbox. E.G.
<input type="checkbox" data-bind="checked : supplierUsers, attr : { value : $data}" />
I have a data table which has two images per column, one that is displayed and also a hidden image that is not. The idea is to dislpay the hidden image on top of the other image if an attribute #{person.isLocked} result set is set to 'T'. My code has a div and within that div has two div's, one for the main image and then one for the image that will be overlayed. (Code below) The image that is to be overlayed has a style attribute display: none; . I need somehow to check to see if the #{person.isLocked} equals 'T', if so then I need to change the css to display:block; else leave it be.
<p:dataGrid var="person" value="myBean.people">
<p:column>
<h:panelGird style="margin-left:auto; margin-right:auto;">
<div>
<div style="position:absolute; z-index:1;">
<p:graphicImage value="image?id=#{person.id}" cache="false"/>
</div>
<div style="position:absolute; z-index:100; display: none;">
<p:graphicImage value="./images/lock.png" cache="true"/>
</div>
</div>
</h:panelGrad>
</p:column>
</p:dataGrid>
The only solution I have come up with is instead of storing 'T' or 'F' in the database as #{person.isLocked}, store the css attribute instead, so I would store 'block' or 'none' and then call the person attribute in the style like so.
<div style="position:absolute: z-index:100; display: #{person.isLocked}">
<p:graphicImage value="./images/lock.png" cache="true"/>
</div>
This seems like a bad design though. I don't want to manipulate the data in my database just for display purposes. Has anyone found a different way of doing this?
I've never used Primefaces, but you could try
<ui:fragment rendered="#{person.isLocked}">
<!-- your div here -->
</ui fragment>