|
-
Oct 6th, 2002, 09:36 PM
#1
Thread Starter
Member
Can't figure this out?
Hello:
I want to thank all that reply.
First, I want to thank the people that answered my question about submitting a form without pressing a button. There answer was <body onload="document.FormName.submit();">
Well I need some more help, can "document.formName.submit();" be use in something like this? (I can't make it work)
<%if x=1 then
"document.FormName.submit();"
else ??????????????(what ever)
end if%>
Or could I place "document.formName.submit();" in a SUB Procedure like this and then call the SUB? (I can't make this work either.)
<%Sub Name()
"document.FormName.submit();"
end sub%>
My problem is that when the user clicks on the submit button(Which is <input type="image/click.jpg width="81" height="20" borden="0">) I have to retreive several pieces of information from several tables in a MDB database BEFORE my FORM can be submitted. I don't want to make the user have to click another button.
Thanks again
-
Oct 7th, 2002, 12:12 AM
#2
Hyperactive Member
Code:
<script language="javascript">
<!--
function submitMe(nNumber)
{
/*
set all your variables here
and do your processing etc
*/
// If the passed in number is greater than 1 then submit the form
if(nNumber >0)
{
document.formName.submit()
}
else
{
// Otherwise display an alert
alert('Form not submitted')
}
}
// -->
</script>
This might give you an idea about how you can go about doing dome processing before you submit a form.
-
Oct 7th, 2002, 01:55 AM
#3
Fanatic Member
hi!!!
try this
<%if number = 1 then%>
<body onload= "document.form1.submit()">
<%else%>
<body>
other functions etc
<%end if%>
-
Oct 7th, 2002, 06:22 PM
#4
Thread Starter
Member
Hello Again:
We are getting closer I think.
OK. I understand the code that was posted in response to my question. (I have not tried it yet however)
But, I need one more answer and then I think I can put it all together and make it work. (Let's hope so)
Here is the code for my click button.(Please note it is not a SUBMIT button, it is of type=image.
<input type=Image src="images/tobuy.jpg" width="81" height="20" border=0>
As you can see it is a button that I made with a button program. The button(image) works when it is pressed. But what I need it to do is call my SUB Procedure when it is clicked. Can this be done? If so, HOW?
My end code when done would follow this format.
SUB rectrans()
"This is where I will have the routine that has to run before my FORM is submitted.
and at the end of this SUB I will have
"document.FormName.submit();"
end sub
This way when the user clicks on the Image(button) it calls my SUB and all of my database routines are done, and then the (JavaScript)"document.FormName.submit();" is fired and my FORM gets posted.
I really want to thank all for your help.
-
Oct 9th, 2002, 06:57 AM
#5
Thread Starter
Member
Can't Figure this out (Getting Closer)
Hello Again:
This is what I have come up with, except it still does not work.
Can someone please tell me why. I took this straight out of the VBSCRIPT REFERENCE MANUAL (WROX PRESS). I just plugged in some of my own code to make it simple for testing. My button shows up and when it is clicked down at the bottom of the browser window it just say (error on page).
<html>
<head>
<title>Untitled</title>
<Script language="VBScript" EVENT="OnClick" FOR="cmdtest">
response.write "this is a test"
</script>
</head>
<body>
<form action="RegNewCustomer.htm" method="POST">
<input type="hidden" name="SOSO" value="YES">
</form>
<input type=Image src="images/tobuy.jpg" id="cmdtest" name="cmdtest" width="81" height="20" border=0>
</body>
</html>
I have tried putting the <input type=Image src="images/tobuy.jpg" id="cmdtest" name="cmdtest" width="81" height="20" border=0> between the from tags but when I do that the form is submitted.
I have to process code before the form can be submitted.
Thanks again.
-
Oct 9th, 2002, 09:51 AM
#6
Black Cat
You are mixing client and server side code. There is no "Response" object anymore - you want document.write or whatever VBScript calls it.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Oct 9th, 2002, 10:27 AM
#7
Frenzied Member
Re: Can't figure this out?
Originally posted by damica
1.
<%if x=1 then
"document.FormName.submit();"
else ??????????????(what ever)
end if%>
2.
<%Sub Name()
"document.FormName.submit();"
end sub%>
Thanks again
Answers:
VB Code:
1.
<%if x=1 then%>
<script>document.FormName.Submit();</script>
<%else
'do watever you need
end if%>
2.
<%Sub Name()%>
<script>document.FormName.submit();</script>
<%end sub%>
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
|