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

Coding issue with retrieving/processing form data

Status
Not open for further replies.

FateFirst

Programmer
Apr 15, 2002
212
GB
hi.

Im just trying to quickly fix a process script that a friend has and im experiencing some issues. The .asp page has a form posted to it

and has to process the data received.

Here is a list of the form elements with their values:

Code:
invoice_data = Project ID '|' Task ID
no_invoice = '[' Time ID ']|' Project ID '|' Task ID
inv_hours_#[#]: <VALUE> = 'inv_hours_' Time ID '[' Project ID ']' : Duration (in hours)

invoice_data: 2496|2
no_invoice: [3092]|2496|2, [3091]|2496|2
inv_hours_3092[2496]: 2
inv_hours_3091[2496]: 6
inv_hours_3123[2496]: 0.25
inv_hours_1970[3020]: 3

Heres the code thats currently being used:

Code:
arrInvoiceData = Split(request("invoice_data"),",")
For i = LBound(arrInvoiceData) to UBound(arrInvoiceData)
	arrInvoiceDataSub = Split(arrInvoiceData(i),"|")
	nIDProject_id = arrInvoiceDataSub(0)
	nIDTask_id = arrInvoiceDataSub(1)
	arrNoInvoice = Split(request("no_invoice"),",")
	For i2 = LBound(arrNoInvoice) to UBound(arrNoInvoice)
		arrNoInvoiceSub = Split(arrNoInvoice(i2),"|")
		nNITime_id = replace(replace(arrNoInvoiceSub(0),"[",""),"]","")
		nNIProject_id = arrNoInvoiceSub(1)
		nNITask_id = arrNoInvoiceSub(2)
		If Cint(nNIProject_id) = Cint(nIDProject_id) AND Cint(nNITask_id) = Cint(nIDTask_id) then
			nIHours = request.form("inv_hours_" & nNITime_id & "[" & nNIProject_id & "]")
			If FormatNumber(nIHours,"2") > 0 then
				sSQLUpdates = "UPDATE [time] SET [time].time_status = 'charged', [time].time_invoiced_hrs = '" & nIHours & 

"' " & _
					   		  "WHERE (([time].time_id)=" & nNITime_id & ");"
				'ExecuteSQL(sSQLUpdates)
				response.write("<b>CHARGE: </b>" & sSQLUpdates & "<br><br>")
			Else
				If TimeCheck(nNITime_id) then
					sSQLUpdates = "UPDATE [time] SET [time].time_status = 'nocharge' " & _
						   		  "WHERE (([time].time_id)=" & nNITime_id & ");"
					'ExecuteSQL(sSQLUpdates)
					response.write("<b>NO CHARGE: </b>" & sSQLUpdates & "<br><br>")
				End If
			End If
		End If
	Next
Next

Now what happens is if the 'Project Id' and 'Task ID' exist in 'no_invoice' then take the 'Time ID' from a match from 'no_invoice' use this

along with the 'Project ID' to get the duration (inv_hours_ etc). If the duration is greater/less-than 0 then update database accordingly.

The first item it handles is correct. It writes:

Code:
CHARGE: UPDATE [time] SET [time].time_status = 'charged', [time].time_invoiced_hrs = '2' WHERE (([time].time_id)=3092);

...but it then goes onto write

Code:
NO CHARGE: UPDATE [time] SET [time].time_status = 'nocharge' WHERE (([time].time_id)= 3091);

This is incorrect...from looking at the 'nIHours'. It appears to be blank on the 2nd loop it does....can anyone see why this would be?

Also, if someone has a better way of handling this process please say ;)

Thanks!

- FateFirst
 
I thought a nice gap from it would help but nope...still confused as to why this isnt working.

- FateFirst
 
oops....

nNITime_id has had a space in front of it so I needed to trim it.

The following fixed it.

nIHours = request.form("inv_hours_" & Trim(nNITime_id) & "[" & nNIProject_id & "]")



- FateFirst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top