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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server side vs Client side

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I mostly write server side (cause I don't know any better)
<%@ Language=VBScript%> This Server side
I have used this for Client side (again cause I don’t know what I’m doing)
<SCRIPT LANGUAGE=&quot;VBScript&quot;>

</SCRIPT>

I want to get the results of a Check box on a form but I'm having trouble mixing the modes?
Here is my code so far:

<form method=&quot;POST&quot; action=&quot;shopping_cart.asp&quot;>
<table border=&quot;1&quot; width=&quot;94%&quot;>
<tr>
<td width=&quot;13%&quot;>Delete</td>
<td width=&quot;14%&quot;>Part Num</td>
<td width=&quot;40%&quot;>Description</td>
<td width=&quot;6%&quot;>Qty</td>
<td width=&quot;11%&quot;>Price</td>
<td width=&quot;17%&quot;>Ext Price</td>
<td width=&quot;17%&quot;>Shipping</td>
</tr>
<%do while not fp_rs3.eof%>
<tr>
<td width=&quot;13%&quot;>
<p><input type=&quot;checkbox&quot; name=&quot;C1&quot; value=&quot;ON&quot;>
<%'If &quot;C1&quot; is checked then delete the part from the shopping cart%>
<%'else if the Quantity is changede update it%>
<% 'other wise work as it is now%>
<td width=&quot;14%&quot;><%=fp_rs3(&quot;PartNum&quot;)%></td>
<td width=&quot;40%&quot;><%=fp_rs3(&quot;Description&quot;)%></td>
<td width=&quot;6%&quot;><INPUT TYPE=text NAME=&quot;qty1&quot; VALUE=<%=fp_rs3(&quot;Qty&quot;)%> size=&quot;2&quot;></td>
<td width=&quot;11%&quot;><%=formatcurrency(fp_rs3(&quot;Price&quot;))%></td>
<%ExtPrice = fp_rs3(&quot;Qty&quot;) * fp_rs3(&quot;Price&quot;)%>
<td width=&quot;17%&quot;><%=formatcurrency(ExtPrice)%></td>
<td width=&quot;17%&quot;><%=formatcurrency(fp_rs3(&quot;Shipping&quot;))%></td>
<%Subtotalprice = ExtPrice + fp_rs3(&quot;Shipping&quot;)%>
<%Totalprice = Totalprice + Subtotalprice%>
</tr>
<%fp_rs3.movenext%>
<%loop%>
</table>
<input type=&quot;submit&quot; value=&quot;Update&quot; name=&quot;Delete&quot;>
</form>
----------------------
TIA

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
I'm not completely clear on what you want, but I'll give it a shot.

First question is:
Is the code you have posted from shopping_cart.asp, making it a recursive form? Or is this page posting to some other page?

So when you jump in the loop (assuming that you aren't at .eof), then you're wanting to just delete the current record if the value of the checkbox is &quot;ON&quot;?

If that's the case, then I'll again assume that there might be many checkboxes on this page, yes? Then you need some dynamic way of naming your checkboxes so that you know what record you're on, where above, you've named them all &quot;C1&quot;.

Additionally, are we checking to see if they've asked for modifications on this same page? Doing my best from your code, and your comments, I think yes, so we'll deal with that, too.

You'll need to make sure that you set a writeable cursorType to the recordset to make all the stuff below work.

One last note before we get started, I'm going to use response.write()'s to output the HTML to the browser, and I'm going to cash the repetitive column widths. Once you set those one time (in your header row), there's no need to continue to set them in subsequent rows. HTML will remember what you said the first time. And as for the response.write()'s, it will make your code much easier to read and is a little faster than mixing and matching it as you have shown above.


Consider this:

while not fp_rs3.eof
'Here's where you're checking the dynamic name,
' which we'll get to in a second

if request.form(&quot;C&quot; & fp_rs3(&quot;partNum&quot;)) = &quot;ON&quot; then

'User has requested a delete, so we'll delete
fp_rs3.delete

else

'User has not requested a delete, so we'll check
' what they have requested and act accordingly

with response

.write(&quot;<tr>&quot;)

'Notice here that I'm dynamically naming the checkbox
' so you'll know which partNum the checkbox goes with
.write(&quot;<td><input type=checkbox name=C&quot; & fp_rs3(&quot;partNum&quot;) & &quot; value=ON>&quot;)

.write(&quot;<td>&quot; & fp_rs3(&quot;partNum&quot;) & &quot;</td>&quot;)
.write(&quot;<td>&quot; & fp_rs3(&quot;description&quot;) & &quot;</td>&quot;)

'let's check to see if they asked for a qty change
if request.form(&quot;qty&quot; & fp_rs3(&quot;partNum&quot;)) <> fp_rs3(&quot;qty&quot;) then
fp_rs3(&quot;qty&quot;) = clng(request.form(&quot;qty&quot; & fp_rs3(&quot;partNum&quot;)))
end if

'Again, I'm attaching this text box to the partNum
' by its name
.write(&quot;<td><input type=text name=qty&quot; & fp_rs3(&quot;partNum&quot;) & &quot; value=&quot; & fp_rs3(&quot;qty&quot;) & &quot;></td>&quot;)
.write(&quot;<td>&quot; & fp_rs3(&quot;price&quot;) & &quot;</td>&quot;)

ExtPrice = fp_rs3(&quot;qty&quot;) * fp_rs3(&quot;price&quot;)

.write(&quot;<td>&quot; & formatCurrency(ExtPrice) & &quot;</td>&quot;)
.write(&quot;<td>&quot; & formatCurrency(fp_rs3(&quot;shipping&quot;)) & &quot;</td>&quot;)

Subtotalprice = ExtPrice + fp_rs3(&quot;Shipping&quot;)
Totalprice = Totalprice + Subtotalprice

.write(&quot;</tr>&quot;)

end with

end if

fp_rs3.moveNext
wend

'save your changes to the database
fp_rs3.update


So that now, there's no question which form element goes with which partNum and it will make it possible to have multiple entries on one page, while letting you keep up with which is which.

Hope it doesn't need too much modification.

good luck! :)
paul
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top