/    Sign up×
Community /Pin to ProfileBookmark

I have a classic ASP application that I have to maintain and have some new enhancements to program into it. What i need to do is validate a couple of fields on the web page form. To do this I need to call a server-side function that will use the value of the field and conduct a JScript ADO function that will execute a stored procedure and return a ‘Y’ or ‘N’ if the record was found or not. I want to pass this value back to the client-side Jscript function and display an alert if the result is “N”. here’s a code snippet.

[COLOR=Sienna]client side JScript[/COLOR]
[SIZE=1]function button_onclick() {
var res;
res = GetEmp(window.document.forms[“frmAddVol”].elements[“EmpNum”].value);

if res == “N” {
alert(“Invalid Emp Num”);
}

}[/SIZE]

[COLOR=Sienna]Server-Side JScript[/COLOR]

[SIZE=1]functionGetEmp(id){
var resval;

….perform ADO database lookup using id as the criteria parameter

return resval;
}[/SIZE]

The server side code resides in a separate file the is included in the web page using the standard <!–#include …–> statement.

My problem is that the script dies when invoking the GetEmp function. The error message is “Object expected”.

what do i need to do to get this to work as described?

Thanks

the Mad Jammer

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterAug 24.2005 — Client side JavaScript cannot use server side functions like that as if they were defined on the client and be able to preform server-side work like that. Besides, your syntaxes are flawed.

Change: [b]functionGetEmp(id){[/b] into [b]function GetEmp(id){[/b]

Change [b] if res == "N" {[/b] into [b] if (res == "N") {[/b]

Give [url=https://webdeveloper.com/forum/showthread.php?t=76930]this[/url] thread a view and it might be of help in your situation.
Copy linkTweet thisAlerts:
@theMadJammerauthorAug 24.2005 — Thank Ultimater. Syntax notwithstanding I still need to be able to perform that server-side code. As it stands there is a bunch of client-side JScript validating already going on when the submit button is clicked. I need to add the server-side scritping in the same place so I don't go off the page. Or perhaps, that's a better idea. After clicking the submit button and validating all of the client-side data perhaps i should href to another page that performs the server-side functions I require. if the data is not valid i can alert the user at that point and return to the original page, although i would have to repopulate all the fields. If the data is valid then I can simply redirect to the next page as would normally happen.

I was just hoping to do all of the verification at the same time and on the same page. Splitting them up may be easier than what you are doing in that other thread you sent.

The Mad Jammer
Copy linkTweet thisAlerts:
@theMadJammerauthorAug 29.2005 — is there a way to invoke a VBscript function from JScript? I've written some embedded JScripts before using Response.Write statements but never tried writing embedded VBscript in JScript.

Thanks

Jammer
×

Success!

Help @theMadJammer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...