|
-
Dec 12th, 2000, 01:22 AM
#1
Thread Starter
Frenzied Member
Add this to your form tag's attributes:
onsubmit="form_onsubmit"
Then add a function called 'form_onsubmit' that loops through the input tags and passes their values to the CleanSQL function.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 12th, 2000, 11:10 AM
#2
Fanatic Member
Monte96,
what I am looking for is the correct syntax for the function you mentioned.I can write a function that passes one part of the form but not ALL fields of the form.
I don't want to have to write a new function for each field. but I don't know how to write just one function an have it loop through all form elements.
I think some kind of collection would work but that is beyond me.
thanks
-
Dec 12th, 2000, 12:41 PM
#3
Member
I have a function that does the same thing and i include it in the asp file's code itsself (but not on the page with the text boxes, on the page that it is being submitted to.)
On the page that gets the submission, I do it when adding the contents of the text box to the database like so (my function name is RA (stands for Reference Apostophes for your info):
MyConnection.Execute("INSERT INTO tblTest (szTest) VALUES ('" & RA(Request.Form("Test")) & "');")
that how i do it atleast.
-
Dec 13th, 2000, 11:24 AM
#4
Thread Starter
Frenzied Member
Ok... assuming that the six input tags are the only text input tags inside the form:
Code:
Sub frmMyForm_onsubmit
Dim intLoop
Dim objInput
Dim strTemp
Set objInput = frmMyForm.tags("INPUT")
for intLoop = 0 to objInput.length - 1
if objInput(intLoop).type = "text" Then
strTemp = objInput(intLoop).value
objInput(intLoop).value = CleanSQL(strTemp)
end if
Next
End Sub
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 13th, 2000, 11:43 AM
#5
Fanatic Member
thanks Monte96
I figured out an even simpler way.
I put the cleanSQL function on the page the is called by the submit button.(page2.asp)
then I did something like this:
dim [all form elements]
elementOne = cleanSQL(request.form("frmName"))
I did this w/ all the variables that came from the form.
super cool.
one thing I found out though was I had to use a function I called dirtySQL and take the two single quotes out and replace them w/ one single quote for display purposes.
anyways it works.
thanks fo your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|