Imagine a webshop where you can buy custom clothes. The user is asked to choose two kinds of colors for his new t-shirt: primary and secondary color. This is done by 2 radiogroups. Depending on the colors the user chooses, an image will be shown, showing the shirt in the selected colors.
My problem is pretty similar, so I will describe it a little bit more abstractly:
I have 2 radiogroups, with 4 radio buttons each on my website:
group 1: A B C D,
group 2: A B C D
Now i want to display an image on my website, depending on the combination of those two groups.
i.e.: user selects A from group 1 and B from group 2 --> display image1
i.e.: user slects A from group 1 and A from group B --> display image2
i.e.: user selects B from group 1 and nothing from group B --> display image3
and so forth...
Primary color:
<label><input type="radio" name="Color1" value="red" id="Color1_0" />Red</label>
<label><input type="radio" name="Color1" value="green" id="Color1_1" />Green</label>
<label><input type="radio" name="Color1" value="blue" id="Color1_2" />Blue</label>
<label><input type="radio" name="Color1" value="champagne" id="Color1_3" />Champagne</label>
Secondary color:
<label><input type="radio" name="Color2" value="red" id="Color2_0" />Red</label>
<label><input type="radio" name="Color2" value="blue" id="Color2_1" />Blue</label>
<label><input type="radio" name="Color2" value="purple" id="Color2_2" />Purple</label>
<label><input type="radio" name="Color2" value="champagne" id="Color2_3" />Champagne</label>
<img id="customimage" src="images/image1.jpg" />
Any ideas on how to do this?! After three days of thinking and Google-research, I've got nothing so far :(
Maybe an Java array will be needed??
I'm open for suggestions :)
You can use jQuery (or a similar framework) to get an event in JavaScript every time the radio button selections are changed, and update the image tag (again using e.g. jQuery) with the URL of the newly selected image.
Changing the image source using jQuery
I would standardize on the names of the images (if you have that level of control) so that you can form the image name based just on the selected radio buttons (e.g. Shirts-Red-Large.jpg), otherwise you can lookup the appropriate image URL using an Ajax query.
Related
Using Thymeleaf th:each loop, whitespace is removed (or can't be added).
Thymeleaf code:
<div>
</div>
I expected:
<div>
Link 1
Link 2
Link 3
Link 4
Link 5
</div>
but html rendered below.
<div>Link 1Link 2Link 3Link 4Link 5</div>
How to add whitespace (in html file new line) using Thymeleaf th:each?
My Thymeleaf version is 3.0.12.RELEASE
If you want the links to be arranged horizontally with a single white space between them (as opposed to arranging them vertically using display:block) then you can use the Thymeleaf synthetic <th:block> element (documented here):
<div>
<th:block th:each="item : ${items}">
</th:block>
</div>
This will give you the same layout as you show in your question, when you run the first code snippet.
Update:
You can also use <span> instead of <th:block>, if you prefer:
<div>
<span th:each="item : ${items}">
</span>
</div>
This will give you the same end result (links arranged horizontally with a space between them), but the HTML generated to produce this layout will, of course, be slightly different.
I create a card with some items inside but i cannot change the width of the v-list-items.
When two v-list-items are on same line the length is 50% for each and i need that the left one be wider.
I made one codepen to show my problem (maybe the problem is how i create the items).
If the left item is wider the ellipsis in the text (long text but not so much as for ellipsis) is not necessary.
CodePen
<v-list-item-content class="pt-0">
<v-list-item-title>long text but not so much as for ellipsis</v-list-item-title>
<v-list-item-subtitle>Today</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-content class="pt-0">
<v-list-item-title align="right" class="font-weight-light display-2">180</v-list-item-title>
<v-list-item-subtitle align="right"> </v-list-item-subtitle>
</v-list-item-content>
You can put your <v-list-item-content> inside a <div class="myDiv"> for example and set your desired width or other styles to that class.
I am using Ruby+Watir+Cucumber+Watir+CeezyPO+.... and in one test I have the next div element:
<div class="slider-importe ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"><div class="ui-slider-range ui-corner-all ui-widget-header ui-slider-range-min" style="width: 50.3384%;"></div><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="left: 50.3384%;"></span></div>
Which is just an amount slider.
In my test I would like to click at any position of the slider and check the amount result that appears in the field text.
I have defined the Page Object for the div:
div(:slider_amount, :xpath => '//*[#id="simulatorParent"]/div[1]/div[1]/div[1]')
And later I can use it in the corresponding step:
page.slider_amount_element.click
Reference about cheezy Page Object: https://www.rubydoc.info/github/cheezy/page-object/PageObject/Accessors#div-instance_method
Using it in that way I can click in the middle of the slider, and this is ok. But, how is possible to click at any position of the slider?
You will need to use Selenium's ActionBuilder - particularily the #move_to method. Unfortunately Watir, and therefore Page-Object, have not yet built a wrapper around actions (feature request #829).
The needed code is:
xoffset = 50 # how far right from the top-left corner
yoffset = 100 # how far down from the top-left corner
page.browser.driver.action.move_to(page.slider_amount_element.element.wd, xoffset, yoffset).click.perform
Where page is your PageObject.
Using xpath, can I get 2 results out of a page at a time? For example, using xpath I can get the first img element:
xpath='//div[#class="forecast-element graphic-box"]/img
...and the next sibling class="forecast-element".
I tried "and" without success:
xpath='//div[#class="forecast-element graphic-box"]/img and //div[#class="forecast-element"]'
also:
xpath='//div[#class="forecast-element graphic-box"]/img and following-sibling:://div[#class="forecast-element graphic-box"]'
I have this html:
<div class='forecast-element graphic-box ' style="background-image:url('/assets/images/forecast/BluePattern.png');">
<h4 style="color: #FFF;">AVALANCHE DANGER <span style="margin-left: 60px;"> MORNING </span><span style="margin-left: 210px;"> AFTERNOON</span></h4>
<img src="/images/forecast/2014-11-23_teton_hazard.gif" alt="Teton Area avalanche hazard rating for 11/23/2014" />
<div style='margin: 2px auto;'><a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px; color: #CCC;'>View full danger scale definitions</a>
</div>
<a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px;'>
<img src="/assets/images/forecast/DangerScale.png" style="margin-left: 150px; margin-top: 5px;" alt='Avalanche danger scale ratings'>
</a>
</div>
<div class='forecast-element'>
<h3 style='margin-bottom: 8px;'>GENERAL AVALANCHE ADVISORY</h3>
Moderate to heavy snowfall combined with strong southwesterly to northwesterly ridgetop winds have created unstable avalanche conditions. New wind slabs have developed at the mid and upper elevations. Snowfall over the past 24 hours has also added weight to existing weak layers near the base of the snowpack. Early season snowfall can easily cloud people’s judgment. Cautious route finding and conservative decision making will be essential for safe travel in avalanche terrain today.</div>
I would like to use following-sibling, as the item is right after the graphic-box element and there are other forecast-elements in the html above and below. BTW, I am using YQL if that makes a difference...
Ideally the results would be (psuedo here):
xpath imgsrc = "/images/forecast/2014-11-23_teton_hazard.gif"
xpath text = "GENERAL AVALANCHE
ADVISORY Moderate to heavy snowfall combined with strong
southwesterly to northwesterly........"
Thanks!
The correct syntax for selecting multiple nodes is |
Try this:
//div[#class="forecast-element graphic-box"]/img | //div[#class="forecast-element"]
As you mentioned, these are two separate query elements. In order to select following elements simply do this
//div[#class="forecast-element graphic-box"]/img | //div[#class="forecast-element graphic-box"]/following-sibling::div[#class="forecast-element"]
In some xpath parsers, this will also work:
//div[#class="forecast-element graphic-box"]/(img|following-sibling::div[#class="forecast-element"])
Trying to display the text of the UILabel in three different lines:
First Line
Second Line
Third Line
But is showing up in single line "First Line Second Line Third Line"
Can the label display multiple lines?
Are you talking about form labels in HTML?
You can add line breaks after each part, or you can wrap each "line" as a span. I think anything else may be invalid.
example:
<label for="some_input">First Line<br />Second Line<br />Third Line<br /></label>
<input id="some_input" type="checkbox" name="input1" />
Or:
<label for="some_input"><span>First Line<\span><span>Second Line<\span><span>Third Line<\span></label>
<input id="some_input" type="checkbox" name="input1" />
then add the CSS:
label span {
display: block;
}
I am using this lable in the gridview. on row data bound i am replacing chr(10) and chr(13) WITH