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

Webclasses and javascript

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to implement javascript to validate my html forms. And its not working, the code I am using to submit the form is below.

<form method=&quot;post&quot; onsubmit=&quot;javascript:validateForm(); action=&quot;clsConsumerStatistics.ASP?WCI=tConsumerStatistics&WCE=Event1&WCU&quot;>

The code goes through and processes the event WCE=Event1, but it does not process the javascript, javascript:validateForm(). I know that my javascript function is correct. I think there is something wrong with the way I wrote the code to submit the form. Does anyone know how to process the javascript first before processing the webclass event????
 
Just a question out of curiousity? Why do you even validate in Javascript? Your webclasses are there just for something like this.

Anyway, change the & just befor WCU in ; or leave the (&WCU) part as a whole and it should work. If it doesn't, get back to me, because I have something familiar and here the javascript is called first and after that the webclass. I use it to paste a parameter from my form to the querystring.

Code:
<form method=&quot;post&quot; action=&quot;clsConsumerStatistics.ASP?WCI=tConsumerStatistics&WCE=Event1;WCU&quot; onsubmit=&quot;javascript:validateForm();>

Jordi Reineman
 
if i've well understood (i'm french) you said that it launches the even and foget the javascript function ?

so you can do this :

function lvalidateForm(){
if (True ) {
parent.window.location=&quot;clsConsumerStatistics.ASP?WCI=tConsumerStatistics&WCE=Event1;WCU&quot;;
} else {
//error message
}

<form method=&quot;post&quot; onsubmit=&quot;javascript:validateForm(); >


this should work
Best regards X-),
Elise
 
Perhaps, but it's not what I mean. When you set the action property in the form to:

clsConsumerStatistics.ASP?WCI=tConsumerStatistics&WCE=Event1;WCU

And sub,mmit the form, In your webclass the event tConsumerStatistics.Event1 is launched. In this event you can access your form data with the Request.Form collection.

If you're not happy with the results you can use response.write to let the user know what it is you're not happy about and just let it be.

If you're satisfied you can redirect to a regular asp page or another webclass by using response.redirect url

OR

if the next page also resides in your webclass set the next page by saying:

webclass.Nextitem = Webclass.your next item{/i]

Good luck!!

Jordi Reineman
 
JJR i wasn't talking to you but was answering to the person who posted the question :eek:) Best regards X-),
Elise
 
JJR,
Sorry, I couldnt get back to you sooner. Work has been really hectic. Anyways validating forms in Javascript would be alot easier to do than in vb. Vb i would have to compile and javascript i wouldnt have to compile.

changing the '&' in front of WCU to ';' did not work. what was the other idea you had. thanks jjr

Tyris,
Bonjour, Merci pour votre aidez, That seems like alot of code, I think if there was a way to place the webclass event and the javascript inside the tag
<form=method post> it would make it alot easier. Merci, je suis desolee pour ma francaise, mais je suis american. Et jai besoin beacoup de praticquer.
 
nflor001,


Vb i would have to compile and javascript i wouldnt have to compile


????

You do use webclasses, don't you?? Because you have to compile your webclass to a dll and install it on the webserver in order to let your code run!

But if you prefer javascript, ok!

This is what I have and I know for a fact it works!

Code:
---in the head section:
function GetDescriptions() {
alert(&quot;Form is submitted&quot;)
}


--- In the Body section

<form name=&quot;zoek&quot; action=&quot;BluePages.ASP?WCI=Zoek&WCE=zoek&Zoek=FormSubmit&quot; method=post target=&quot;_top&quot; onsubmit=&quot;GetDescriptions()&quot;>

WCI lets the webclass know which template to use, in my case the template zoek (search in English - it's Dutch-). WCE lets the webclass know which WebClassEvent to Raise. In my case the zoek event. I've added an extra parameter Zoek=FormSubmit for internal purposes.

If this still doesn't help you, submit your html code, so we can take a look at it.

Good luck,

Jordi Reineman

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top