i am creating a web app and i have a dropdownlist
<select id="drdsearch" ng-model="drd" style="margin-top:-39px; margin-left:300px; height:30px; width:200px; font-size:12px;"><option value="select">select</option>
<option value="default">Default</option>
<option value="venue">Venue Name</option>
<option value="date">Date</option>
</select>
with these textboxes
<input type="text" ng-hide="true" ng-show="drd=='default'" placeholder="d" name="default">
<input type="text" ng-hide="true" ng-show="drd=='venue'" placeholder="e" name="venue name">
<input type="text" ng-hide="true" ng-show="drd=='date'" placeholder="l" name="Date">
i used angularjs for (hide/show)textboxes but now when i run my program dropdown automatically included an extra blank option field
now there are four fields in my dropdow
1st ( )blank
2nd default
3rdvenue
4thDate
what i need to do to remove the extra (blank option) from the dropdownlist
Initialize the value in your $scope.drd with 'default' and you should be fine.
Related
If you select option 2 for example, I want to send both the value 2 (for the amount of books to be added) but also the Book_ID for the chosen book.
So in my method that retrieves the form I expect to get both an integer value of 2 and also an integer value for my Book_ID.
I was hoping you could do something like
<option value=#ShoppingCartItem.Book_ID value="1" >1</option>
but that obviously didn't seem to work.
Below is a code snippet from my current View.
#foreach (Lab2.Models.ShoppingCartDetail ShoppingCartItem in Model.ShoppingcartList)
{
<tr>
<td>#ShoppingCartItem.Title</td>
<td>#ShoppingCartItem.Author</td>
<td>#ShoppingCartItem.Price :-</td>
<td>#ShoppingCartItem.NumberOfBooks</td>
<td>
<form action="UpdateNumberOfBooks" method="POST">
<div class="form-group">
<select class="form-control" id="NumberOfBooks" name="NumberOfBooks" onchange="this.form.submit()">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</form>
</td>
</tr>
}
If it's possible, how should my method look that retrieves this information?
Just add that value as an <input> to your form. For example:
<input type="hidden" name="Book_ID" value="#ShoppingCartItem.Book_ID" />
This would include the Book_ID as a separate value in the same <form>.
how should my method look that retrieves this information?
Presumably you have a method which receives something like this, no?:
public IActionResult UpdateNumberOfBooks(int numberOfBooks)
If that's the case, you'd just include this second value as well:
public IActionResult UpdateNumberOfBooks(int book_ID, int numberOfBooks)
Or if NumberOfBooks is included as part of a model, you'd add Book_ID to that model. Basically, however you currently receive the one value you have now, you'd add the new value alongside it.
I need to know a way to show an alert with all the selected items after pressing a button, could be with the code behind or jQuery, any of them work, this is a sample:
<label for="sel2">Mutiple select list (hold shift to select more than one):</label>
<select multiple class="form-control" id="sel2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
The output should be a regular alert with all the selected items, thanks in advance.
(Edit: Wrong sample)
HTML :
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<button type="button" id="btn">Alert Selected</button>
</div>
Script
<script>
$("#btn").click(function(){
alert($("#sel1").val());
});
</script>
In my cshtml page I have a select element with multiple options. Below it I have a button which needs the value of the selected option. How do I reference the value of the selected option?
<select>
<option value="1">1</select>
<option value="2">2</select>
<option value="3">3</select>
</select>
<input type="button" value="submit" onclick="location.href='#Url.Action("MyAction", "MyController", new { property = (how do i reference our selected option value here?)})'"
I have a drop-down list like
<div class="form-group">
<label>
<span>Status:</span>
<select name="status" id="status">
<option value = ''>Please select</option>
<option value="Passed">Cleared</option>
<option value="Failed">Redo</option>
<option value="Improvent" value ="second level improvement" value="third level improvement">Pending</option>
</select>
</label>
</div>
I am fetching data from SQL using asp.net webmethod. How can I have multiple values inside option tag? In my database, if I have either improvement or second level improvement or third level improvement I should display as pending. In database value, if the value is passed I was able to display cleared and if the value is failed I was able to display Redo. I am not sure how to have multiple values in option tag. If it can be done on the server side can anyone explain how can i do with asp.net?
my query is , i have a combo box inside my form in html , i would like to pass the value of the selected item of the combo box to the server side which is a aspx page,
<form method="POST" action="page.aspx">
<input id="customerName" name="customerName" type="Text" />
<input id="customerPhone" name="customerPhone" type="Text" />
<select id="combobox" >
<option>df</option>
<option>as</option>
</select>
<input
</form>
value="Save" type="Submit" />
in the server side i use the following set of codes to select the textbox value
string n = String.Format("{0}", Request.Form['customerName']);
but how to get the values of the combo box selected value
please help me
thanks in advance
You can try fixing your html:
<form method="POST" action="page.aspx">
<input id="customerName" name="customerName" type="text">
<input id="customerPhone" name="customerPhone" type="text">
<select id="combobox" name="combobox">
<option value="df">df</option>
<option value="as">as</option>
</select>
<input value="Save" type="submit">
</form>
The selected value will be posted as Request.Form['combobox']