How to make Drop down box values as link - spring

I want to list products in ascending and descending order by price.I have these 2 values in drop down list.So when i select ascending from drop box, i want to use it as #requestmapping value in controller.How can i do it in jsp and spring.Please suggest me.

I'm going to assume you have your product list HTML setup already.
Your menu should look something like this:
<form method="GET">
<select name="sort" onchange="this.form.submit();">
<option value="Price,ASC">Ascending</option>
<option value="Price,DESC">Descending</option>
</select>
<button>Go</button>
</form>
When the user selects an item in the menu or clicks the button it will submit the form with the URL like http://example.com/product-list?sort=Price,ASC [or DESC]
Your server would then need to grab those parameters, sort the output and return the output.
I used that particular URL format as it's compatible with Spring Data JPA.

Related

how to add check box inside select tag

I am trying to select multiple values inside a drop down using check boxes, I confused how to attain without changing TLD file. ie each option for the select will have the check box
sample code which iI work is below
<form:select path="brandIds" id="brandDropdownSelectId" tabindex="31" multiple="true" size="4" >
<option value="0">Select Brand</option>
<form:options items="${brandList}" itemValue="brandId"
itemLabel="brandName" checkbox="true"/>
</form:select>
You can use external component like Twitter Bootstrap Multi-select
You can never use Checkbox inside a Select tag.
But, to solve this issue, we make use of CSS+Javascript to render the effect.
You define a empty select tag with a javascript function to alter the visibility of the checkboxes on click, and CSS plays the role of portraying the rendering in single effect.
This might help you:
Adding checkboxes inside a Select Tag

Calling a Select_List with Watir-Webdriver Without an ID/Name

I'm currently having trouble calling a Select_List that does not have a name/ID (as the title states).
The HTML for the Select List is:
<select dojoattachpoint="userSelector" size="15" multiple="">
<option value="_W2kn2sdAEeSmeMQKjIY8Ug"></option>
<option value="_gkeqUBUqEeG7h6M2lwbcyg"></option>
</select>
What I need to do is select one option in the select list and then click a button, but I can't select the option if I don't know how to point at the list itself.
Note: This is done in Firefox if it matters.
Because "dojoattachpoint" is not a valid attribute for a Select Element per the html5 spec, you can't use it directly. You can access it with css, though:
el = browser.select(css: "[dojoattachpoint='userSelector']")
You could also look into making the site's code html5 compliant, since I think dojo supports data tags: 'data-dojoattachpoint' or the like. Then your selector could be: el = browser.select(data_dojoattachpoint: 'userSelector')

Check product has more than one option in dropdown Magento

HI i need something unusual , i want like
if my product has more than one option value
than it should show in dropdown
otherwise if it has only one option value
than i need to show without dropdown or as a text only.
Please suggest me how can i do this.
like like if
<select name="select_box" id="select_box">
<option value="one">1</option>
<option value="tow">2</option>
<option value="three">3</option>
<option value="three">4</option>
<option value="three">5</option>
<option value="three">6</option>
</select>
the dropdown has more than one opton than i need to show the above dropdown and if the
<select name="select_box" id="select_box">
<option value="one">optionname only</option>
</select>
dropdown has one option than i need to show optionname only as a text.This will not be a require field.
3-4 files are included in this process.
You can see that by enabling "Template path hints" from admin->settings->advanced->developer.
anyway check these files
if its a dropdown the you can change in this file (Remember do changes in your theme not in base)
frontend/base/default/template/catalog/product/view/options/type/select.phtml
Another files in this process(check xml)
frontend/base/default/template/catalog/product/view/options/wrapper.phtml
frontend/base/default/template/catalog/product/view/options/js.phtml
frontend/base/default/template/catalog/product/view/options.phtml
Another way:
Goto
App/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
here find getValuesHtml() and check the code and edit as per your need
(DO NOT EDIT CORE FILES ALWAYS OVERRIDE FOR EDITING PURPOSE)

Install niceforms. Send options to cart

I want to install niceforms on Magento.
How does it work? I wrap the product option "select" info form tag so it looks like
<form class ="niceform">
<divs for niceform>
<select id="" class="product-custom-option required-...." ...>
</form>
So
div for niceforms contains duplicate of select in div-format. So I managed to write a function which will watch selected element from divs and select it in product-option select. And then reload price. But it doesn't sends product-options to cart.
How can I solve this problem?
The problem was that niceform was in another form.

loading a new form with ajax

i have a combo box what i want is whenever a new option from combo box is selected new form is loaded below the combo box with out refreshing the page can some one provide the script
Yes download the jQuery and you can simpley do with jQuery/Ajax.
<select onChange="$('#formDiv').load(this.options[this.selectedIndex].value)">
<option value="/pages/form1.html">form1</option>
<option value="/pages/form2.html">form2</option>
</select>
<div id="formDiv"></div>
This is basic structure I gave, You can enhance it to work it in more secure way.

Resources