Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call a VBScript function with a button? 1

Status
Not open for further replies.

Beracosta

Programmer
Oct 25, 2000
47
0
0
SE
How do i make a VBScript function to activate when i press a button. The button is written in a asp file and the function that will be called should empty the shopping basket. Can anybody help me with this? (I think that James can ;)
 
It didn't work. how the hell should i solve this? i'm really stuck with this now!
 
should i mail it to u? or should i post it here?

on your pc? are u working on a mac?
 
Hi,
had alook at your code but I can't quite seem to get at what you are trying to do. Easiest way to do this is if I give a scenario and then the solution.

Here goes....

SCENARIO

User has a basket shown in a list box.
List box shows Merchant, Item, and Quantity.
Each row in the listbox has a unique identifier in the database.

Bit of code to show listbox...

Code:
if oRS.RecordCount > 0 then
    while not oRS.EOF
        Response.Write &quot;<OPTION name=&quot;&quot;merchant&quot;&quot; value=&quot;&quot;&quot;
        Response.Write oRS(&quot;MerchantID&quot;)
        Response.Write &quot;+&quot;
        Response.Write oRS(&quot;BasketEntryID&quot;)
        Response.Write &quot;&quot;&quot;>&quot;
        Response.Write oRs(&quot;Quantity&quot;) 
        Response.Write &quot; st &quot; 
        Response.Write oRs(&quot;Name&quot;)
        Response.Write &quot; for &quot;
        Response.Write oRs(&quot;Price&quot;)
        Response.Write &quot; $ each </option>&quot;
        oRS.MoveNext
    wend
end if

Response.Write &quot;<INPUT name=&quot;&quot;DeleteItem&quot;&quot; value=&quot;&quot;DeleteItem&quot;&quot; Type=&quot;&quot;Button&quot;&quot;>&quot;
Response.Write &quot;<INPUT name=&quot;&quot;DeleteMerchant&quot;&quot; value=&quot;&quot;DeleteMerchant&quot;&quot; Type=&quot;&quot;Button&quot;&quot;>&quot;

The above form assumes that there is a form decleration before it were the method is set to
Code:
POST
.

In the ASP that this form posts to the following code will exist:

Code:
dim intMerchant, intItem

intMerchant = Left(Request.Form(&quot;merchant&quot;), InStr(Request.Form(&quot;merchant&quot;),&quot;+&quot;) - 1)
intItem = Right(Request.Form(&quot;merchant&quot;), Len(Request.Form(&quot;merchant&quot;)) - InStr(Request.Form(&quot;merchant&quot;),&quot;+&quot;))

if Request.Form(&quot;DeleteItem&quot;) <> &quot;&quot; then
    strDeleteSQL = &quot;DELETE FROM myTable WHERE MerchantID = &quot; & intMerchant
else
    strDeleteSQL = &quot;DELETE FROM myTable WHERE ItemID = &quot; & intItem
end if
[code]

this show sthe most important part.

James :-) James Culshaw
jculshaw@active-data-solutions.co.uk
[URL unfurl="true"]http://www.active-data-solutions.co.uk[/URL]
[URL unfurl="true"]http://www.brainbench.com/transcript.jsp?pid=193305[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top