<td>Branch</td>
<td>
<select name="branch" type="text">
<option value="0">Select Branch</option>
<option value="CE">CE</option>
<option value="IT">IT</option>
</td>
<td>Batch</td>
i.e if i have branch field in my jsp form
so my branch firld contains 2 inputs as 1.CE & 2.IT.
So when i click on CE ,so it have to show me A1,A2,....A5 & when i click on IT, it will have to show B1...B5 from which we can select any one of the field.
So, pls help me for above program.
Here is my code.
Pls help me what code should i write in "Batch" field""
you have to register onChange() event of the branch and call an javascript function which will populate the batch field accordingly.
Related
I am trying to build a custom build Jira Plugin, on the UI of plugin I am displaying select dropdown which consist of list of Issue Types.
I need to make option value "ALL" as default one for that select dropdown. I have written following code for that.
<label for="issue-types" >Issue Type(s):</label>
<select onchange="disableIfNoIssueTypeSelectedMandate()" class="multi-select" multiple="multiple" id="issue-types-mandate" name="issueTypes[]">
#foreach ($issueType in $allIssueTypesInProject)
<option value="$issueType.get("id")">$issueType.get("name")</option>
#end
</select>
</div>```
Can anyone please help me to know how to set default value in this select dropdown?
probably you should use <option selected="selected" value="$issueType.get("id")">$issueType.get("name") but with the default string values that you need
I have a variable that is obtain inside each block in thymeleaf. I want to send that variable to a certain method in my controller. The limitation is that the variable is obtain inside a block which makes it local, not accessible global.Hence I get an error while trying to use it. How can I move inside the scope to get the variable so as I can use it global in thymeleaf.
<form th:action="#{/masomo/somo(date=${dateMpya.date})}" method="POST">
<select id="date" name="date" required="true">
<option value="none" selected disabled hidden >
Select a Date
</option>
<th:block th:each="somoChagua : ${masomoChagua}">
<option th:each="dateMpya: ${somoChagua}" th:value="${dateMpya}" th:text="${dateMpya.date}" ></option>
</th:block>
</select>
<button type="submit"><i class="fa fa-search"></i> </button>
</form>
There can be many different "dateMpya" objects for each "somoChagua".
But there is only one submit button.
So which "dateMpya" should be used for the submit button value?
I think what you are actually trying to do here is get the value of the "dateMpya" which the user selected in the drop-down. Is that right?
If that's the case there is no need to add any attributes to the submit button. You would access that value by using the name of the select element, which is "date".
EDIT: For the same reason you also need to remove the (date=${dateMpya.date}) part of the form action as well. The value selected in the drop-down will automatically be submitted under the name of the select element "date", it does not need to be specified.
Could anyone please explain me how to avoid the duplicate enters of records in to the select box options during editing the page.I am using java to develop web application I am very new to that,I need to remove the duplicates from the select box option while editing.Could anyone please help me .
Sample Code
<td><select property="employeestatus" value="" id="employeestatus">
<c:if test="${employee.employeestatus!=null}">
<option value="${employee.employeestatus}">${employee.employeestatus}</option>
</c:if>
<option value="">Select</option>
<option value="Active">Active</option>
<option value="Terminated">Terminated</option>
<option value="Deceased">Deceased</option>
<option value="Resigned">Resigned</option>
<option value="InActive">InActive</option>
</select>
<html:errors property="employeestatus"/>
<p id="employeestatus" style="color:red"/>
</td>
I would suggest to add the selected attribute on the option corresponding to your "employeestatus" variable instead of duplicating this option on the first line.
See HTML option selected Attribute
By the <html:errors ...>, I gess you use Struts 1. If it's true, I would use the
<html:select ...> tag and
<html:options or optionsCollection ...>
with java Map store in some context (servlet, session or request) to configure options. That struts tag will select the good option corresponding to your variable value.
See Struts <html:select ...> doc
I want to set value differently and option differently in an Select tag
ex.
<select name="myselect">
<option value="1">one</option>
</select>
that mean i have two list from DB
1)one is Id of username to which i want to keep in value of select
2)second is username which is other. this i want to keep in between option tag
Please Help
thanks
Rakesh
If you are sure that both of the list are in sync (in terms of index , i.e. user Abc from list a is at the top so id of the Abc in other list is at the top)
You can do it following way
<c:forEach var="idOfPerson" items="${listOfId}" varStatus="status">
<option value="${idOfPerson}">${listOfNames[status.index]}</option>
</c:forEach>
I am new to a Java environment and JSP. My question is, is is possible to detect the value of a select dropdown option and create a small if statement depending on this value?
For example:
<select id="my_select">
<option value="-1">Option 1</option>
<option value="0">Option 2</option>
</select>
<c:if test="${id eq -1}">
Show this
</c:if>
<c:if test="${id gt -1}>
Show this
</c:if>
Thanks guys!
No, you have to first realize the lifecycle of the JSP. The output is formed on the server and sent to the client. Then the client performs some actions and possibly submits a form back to the server.
In your case you have two options:
use javascript
submit the form holding the dropdown, and depending on ${param.id} show one or the other