Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 selection of combo box in asp

views
     
TSguest18
post Feb 6 2006, 04:13 PM, updated 20y ago

hisap hisap hisap
*******
Senior Member
2,236 posts

Joined: Jan 2003


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
post Feb 6 2006, 04:40 PM

Getting Started
**
Validating
297 posts

Joined: Jan 2003
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 tongue.gif
shinchan^^
post Feb 6 2006, 04:44 PM

K66
*********
All Stars
21,256 posts

Joined: Jan 2003
From: Pekopon


CODE
<select Name="fruitName">
 <%do while not resultSetFruit.eof=true
     Response.Write "<option value=" & resultSetFruit("FruitName") & ">" & resultSetFruit("FruitName") & "</option>"

     resultSetFruit.MoveNext
           loop %>
             </select>

TSguest18
post Feb 6 2006, 04:57 PM

hisap hisap hisap
*******
Senior Member
2,236 posts

Joined: Jan 2003


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^^
post Feb 6 2006, 05:08 PM

K66
*********
All Stars
21,256 posts

Joined: Jan 2003
From: Pekopon


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^^
post Feb 6 2006, 05:13 PM

K66
*********
All Stars
21,256 posts

Joined: Jan 2003
From: Pekopon


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
post Feb 6 2006, 06:07 PM

Enthusiast
*****
Senior Member
963 posts

Joined: Jan 2003
If the database is small, it's better to use javascript

 

Change to:
| Lo-Fi Version
0.0157sec    0.36    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 06:29 AM