Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Javascript and ASP Forms
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Javascript and ASP Forms

 Post Reply Post Reply Page  <12
Author
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2007 at 6:33pm
Brolin99, the last code snippet that I gave you unfortunately doesn't work in firefox so I'm going to have to do some additional work on the code and test it in IE 7, Firefox, Opera. I will also endevour to do the last bit that you added and show you how to get all this information into an ASP script. That may take a day or two to get this lot on though so don't worry I'm on it
Back to Top
Brolin99 View Drop Down
Groupie
Groupie
Avatar

Joined: 03 May 2003
Location: New Zealand
Status: Offline
Points: 58
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brolin99 Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2007 at 3:25am
Thanks Bootcom - you're a legend!
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 10 January 2007 at 8:05pm
Just to give a quick update so you don't think i've forgotten about you Tongue
 
I've now sorted the code out for the totalling up of the numbers as you wanted. I'm just sorting out the commenting and the final form submission and will have this available to you tomorrow (hopefully).
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2007 at 6:48pm
Ok heres the first page ....
 

<html>
<head>
<script>

function addRow1(){

var t = document.getElementById("someID")

var r = document.getElementById("someID").insertRow(t.rows.length - 1);
var c1 = r.insertCell(0)
var c2 = r.insertCell(1)
var c3 = r.insertCell(2)
var c4 = r.insertCell(3)

c1.innerHTML = "Random " + t.rows.length
c2.innerHTML = "Service"
c3.innerHTML = 12  + t.rows.length
c4.innerHTML = "0"

var cost = 0
var payment = 0

// Set the row attribute
r.setAttribute("id", document.getElementById('someID').rows.length)
    var count=0;

for (i=1; i < t.rows.length -1; i++) {

        for (j=0; j < t.rows.cells.length; j++) {
             
     }
cost += parseInt(t.rows.cells[2].innerHTML)
payment += parseInt(t.rows.cells[3].innerHTML)
    }

t.rows[t.rows.length - 1].cells[1].innerHTML = "£" + cost
t.rows[t.rows.length - 1].cells[2].innerHTML = "£" + payment
}

function completeMe(){
// Im completing the script with HTML entries into the table

var t = document.getElementById("someID")

var cost = ""
var payment = ""

for (i=1; i < t.rows.length -1; i++) {

        for (j=0; j < t.rows.cells.length; j++) {
             
     }
if(i > 1){
cost += "+"
payment += "+"
}
cost += parseInt(t.rows.cells[2].innerHTML)
payment += parseInt( t.rows.cells[3].innerHTML)
    }

document.addForm.cost.value = cost
document.addForm.reciept.value = payment
document.addForm.submit()
}

</script>
</head>
<body>
<a href="javascript:addRow1()">Add</a>

<form name="addForm" method="post" action="save.asp">

<input type = "hidden" name = "cost">
<input type = "hidden" name = "reciept">

<table id="someID">
  <tr>
    <th>Name</th>
    <th>Payment Type</th>
    <th>Cost 1</th>
    <th>Payment 1</th>
  </tr>
  <tr>
    <td>BootCom</td>
    <td>Works Completed</td>
    <td>0</td>
    <td>200</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td>0</td>
    <td>200</td>
  </tr>
 
</table>

</form>

<a href="javascript:completeMe()">Finish</a>

</body>
</html>

As you can probabaly see this page is up for lots of editing, just to make it do exactly what you want it to do. Use prompts to fill in the table values or use inputs.
 
Page 2 - Bung it all in a db / show it to user ... whatever you want it to do
 
<%
Dim input1
Dim input2
Dim intArrayLoop

input1 = split(request.form("cost"), "+")
input2 = split(request.form("reciept"), "+")

' Test to see if the js worked.
For intArrayLoop = 0 to uBound(input1)
response.write(intArrayLoop & " " & input1(intArrayLoop) & "<br />")
response.write(intArrayLoop & " " & input2(intArrayLoop) & "<br />")
Next
%>
 
There you go. Im now going to use this code to do something similar on my site. Happy coding
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.