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

Validating a Textbox entry by using an Array - ASP/VBScript

Status
Not open for further replies.

catbutt

Programmer
Joined
Aug 9, 2005
Messages
2
Location
US
I have a webpage that has a textbox. The user will enter a 5 digit code into the box and then click a <A HREF> link. I've been trying to build a Function called "VSerial_onclick()" to check that the code is in an earlier built Array before anything else happens...The function will include a For Loop until, found = "true", then exit for...there will be only one possible match in the array

I'm guessing I'm having trouble because the Array is built "outside" of the html.

Does anyone have any suggestions.

Since the whole page is ASP/VBScript I'd like to keep it similar...not a deal breaker...

The code for the textbox is:

Code:
<FORM ACTION='' METHOD='' Name=MyForm>
ENTER SERIAL # HERE : <input type=text Name=XUIC SIZE=5 Maxlength=5 value=''>
<A HREF=# id=VSerial  Title='Click Here to View Report'>&nbsp;view</a>
</FORM>

Any Ideas?

Steve
 
something like this:
Code:
<A HREF=# id=VSerial  Title='Click Here to View Report' [red]onclick='viewSerial(code);'[/red]>&nbsp;view</a>
then you can have
Code:
<script>
viewSerial(code){
'declare your array
'do your for loop here
'to match the code
}
</script>

-DNG
 
DotNetGnat,
My question will expose my lack of knowledge...please be patient.

I understand when I click the tag it will look for and run the function viewSerial. What sort of thing goes where you have "(code)" in the onclick='viewSerial(code);'?

Also, in the function where I "declare my array", do I need to build a new array? If so, is there a way I can use any part of the existing one? If not, do I need to place this function in a specific location on my page (header, body, before the header...) for it to see the array that already exists?
The Array (BOArray) is built from a stored procedure on SQL Server2000 and is built between the </Head> and <Body> tags

I didn't build most of this page...I'm not sure why things are where they are.
I apologize if this question seems to be too elementary.

CB
 
as far as your first question is concerned...

you can have something like this:

onclick='viewSerial(<%=request.querystring("code")%>);

if you are getting the code value using a querystring from another page...you can also use request.form("code") if you getting it from another form...it actually depends on how you are getting your code value...you can also try this.value...what i mean any valid value can go in the place of code in this line...

onclick='viewSerial(code);

Now for question two..your code outline should look something like this
Code:
<html>
<head>
</head>
<body>
</body>
<script>
</script>
</html>

and yes you can use the array that you already have in your head section inside the script part..

just give it a try and see how the things work...post back if you have any other questions...
-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top