Outline ·
[ Standard ] ·
Linear+
selection of combo box in asp
|
TSguest18
|
Feb 6 2006, 04:13 PM, updated 20y ago
|
|
I manage to populate a combo box with item from a database how if I want to copy information inside that particular selection into another table ?
for example I populate combo box from table fruit and I select apple and inside the row got amount of how many apple there is avaliable and want to add the amount to table call amount
and display this amount out
|
|
|
|
|
|
rebel without a cause
|
Feb 6 2006, 04:40 PM
|
Getting Started

|
just get the id from the combobox of selection through request.form for example and then throw into the sql statement to update or insert say something like: update AmountTable set ValueColumn = (select AmountColumn from FruitTable where PrimaryId = 'SelectedValue' ) + (select ValueColumn from AmountTable where PrimaryId = 'SelectedValue') where PrimaryId = 'SelectedValue' you need to be more specific if you want more specific answer
|
|
|
|
|
|
shinchan^^
|
Feb 6 2006, 04:44 PM
|
|
CODE <select Name="fruitName"> <%do while not resultSetFruit.eof=true Response.Write "<option value=" & resultSetFruit("FruitName") & ">" & resultSetFruit("FruitName") & "</option>"
resultSetFruit.MoveNext loop %> </select>
|
|
|
|
|
|
TSguest18
|
Feb 6 2006, 04:57 PM
|
|
QUOTE(shinchan^^ @ Feb 6 2006, 04:44 PM) CODE <select Name="fruitName"> <%do while not resultSetFruit.eof=true Response.Write "<option value=" & resultSetFruit("FruitName") & ">" & resultSetFruit("FruitName") & "</option>"
resultSetFruit.MoveNext loop %> </select> if I want to select 1 item from the displayed combo box and add it to another table how ?
|
|
|
|
|
|
shinchan^^
|
Feb 6 2006, 05:08 PM
|
|
make a submit type button then the page form action post back to same page
asp top page detect post back and fruitname and update table
or use a javascript function detect the combobox change, and post back then do the update
i think use button better
|
|
|
|
|
|
shinchan^^
|
Feb 6 2006, 05:13 PM
|
|
1st) <FORM NAME="fmMain" ACTION="Fruit.asp?fruitName=<%=fruitName%>" METHOD="post" TARGET="_top">
2nd) <input value ="View Bill" type="submit" name="bttSubmit" />
3rd) 'Request balik the fruitname on the top page <%@ LANGUAGE="VBSCRIPT" %> fruitName= Request("fruitName")
if fruitName="" then Response.Write "<script>alert('Please Select The Fruit Type.')</script>" else ' SQL UPDATE STATEMENT HERE ' ' '
end if
%>
|
|
|
|
|
|
sinister
|
Feb 6 2006, 06:07 PM
|
|
If the database is small, it's better to use javascript
|
|
|
|
|