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

Check Box & Form submission Question

Status
Not open for further replies.

scribbler

MIS
Feb 4, 2002
206
GB
Yet again, please can anyone point me in the right direction. I have an asp page which has numerous check boxes on, all of which have a numeric value. I want a total value on the page to recalculate itself each time a user either checks or unchecks one of the boxes depending on the checkbox value.... if that makes sense. I guess I would have to submit the page as a form and refer back to itself with the ammended value but am not sure if that's the correct way to do it.
 
This is really a javascript question.

See thread216-967897 and let me know if you have questions.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Ideally I would like the total value amount to be increased/Decreased with each checkbox tick/untick and when the user is ready then the form to be submitted.
 
I know mwolf00 says this is really a javascript question and that I should know javascript but my pages are almost all written in html, asp with a littl ehelp from various sources of javascript.

Basically I have retrieved, using html & asp, from my web based database numerous items (along with their respective checkboxes) and I would like the page to hold a total which is ammended each time a user checks/unchecks one of the boxes. Is this not possible in asp ? if not then is it possible, using my resulting asp page to add bits of javascript to make it work ? My aim is to have the total value eventually passed to another page for emailing possibly.

I suppose it's getting a bit like a shopping cart scenario but without going the whole hog as once the total is aquired thats as far as the user goes.
 
>Is this not possible in asp

No. ASP is exicuten in the server and can't be solved there unless you want to make a new page request whenever the checkbox is clicked (and you don't want that).

> is it possible, using my resulting asp page to add bits of javascript to make it work

Of course. You did see the thread mwolf00 mentioned, right?

/Per
[sub]
www.perfnurt.se[/sub]
 
Yes I looked at the thread that mwolf00 mentioned but albeit worked well it was all javascript. What I would like to achieve is to use the existing page I have now ,which contains a list of asp variables from a database, and I'm looking for some help on how I integrate this with javascript.

Code as below....

response.Write("<BR>Selectable Options For This Are As Follows;<BR><BR>")

response.write ("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr bgcolor='#FFFFFF'><td width='5%'>&nbsp;</td><td width='15%'>Option Code</td><td width='40%'>Option Description</td><td width='20%'>Option Type</td><td width='15%'>Option Price</td><td width='5%'>&nbsp;</td></tr>")

OptionDescRS.CursorType=2
OptionDescRS.LockType=3
While SelectableOptionsRs.EOF=false
response.write ("<tr><td>&nbsp;</td><td>") & SelectableOptionsRs("Code") & ("</td>")

'Next open up the Option desc. table and read in the matching Option Description
OptionDescSQL ="SELECT * FROM tbloptiondesc WHERE OptionCode = '" & SelectableOptionsRs("Code") & "'"
OptionDescRS.Open OptionDescSQL, con
If OptionDescRs.EOF=false then 'If recordset is not empty then it must contain matching codes
response.write ("<td>") & OptionDescRS("OptionDesc") & ("</td>")' Options_Desc

else
response.write ("<td>") & ("NO DECRIPTION FOUND") & ("</td>")
End If
response.write ("<td>") & " " & SelectableOptionsRs("Type") & ("</td>") & ("<td>") & SelectableOptionsRs("OptionTotal") & ("</td></tr>")

OptionDescRS.close

SelectableOptionsRs.MoveNext
Wend
Set OptionDescRS = Nothing
response.write ("</Table>")
 
It has to be done client side, after the person viewing the page makes their choices with the checkboxes, which rules out using ASP. The only practical way to do this is with Javascript, like you've already been told.

Lee
 
Ok trollacious can you, or anyone else, help by suggesting how I might achieve this using my existing code ?

 
Not sure I understand what the problem is. Javascript is just some content of a HTML page, that may or may not be generated with the aid of ASP.

Code:
<%
sub WriteJavaScriptCrap(txt)
%>
<script language="javascript">
  <!--
  alert("<%=txt%>");
  // -->  
</script>
<%
end sub
%>

<html>
  <head></head>
  <body>
<%
  WriteJavaScriptCrap "Hello world"
%>
  </body>   
</html>


/Per
[sub]
www.perfnurt.se[/sub]
 
Sorry PerFnurt I'm not explaining myself very well.

What I need to do is somehow using the asp code variables I receive from my database I want to know how I incorporate Javascript into the page.

I retrieve data from a database based on selections from a previous page using asp but the page layout at that point is in html & asp. How do I incorporate javascript in say he following code as it is asp not javascript so that I can perform the calculation shown by mwolf00............

<%
response.write("<form>")
response.write("<input type='checkbox' name="option1">ASPvariable1")
response.write("<br>")
response.write("<input type='checkbox' name="option2">ASPvariable2")
response.write("</form>")
%>


Obviously I have a lot more lines of check boxes to handle but the principle would be the same presumeably..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top