checking input with button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that is filled out online. One of the fields is the serial
number which is encoded to include the date. This is used to determine if
the unit is under warranty or not.

How can I put in a push button that will run a routine to check the serial
number and see if it is under warranty? I can generate the code for
validation just fine, I simply can't figure out how to execute the code on a
button push. I would prefer to have the code inline, not on a separate page.

I am using asp pages.
 
Dave,
You'll need to do some custom coding on the server. Classic asp is a
little trickier than ASP.Net. If it's classing ASP you'll need to have an
extra hidden form field that let's you know when you're posting back to the
page. Then in ASP you can see if there is such a hidden field and if there
is, it means that a button has been clicked and you're posting to the page
(if it isn't it means that no form has been submitted and you don't need to
process). Then you have to talk to a database somewhere and get some sort of
result after performing your business logic to determine warranty. You'll
have to perform another operation based upon the results, whether it's
printing out additional code to let them know it's not under warrenty and
what they should do, or that it is under warrenty and what to do next.

Basically, you're going to have to do some coding by hand since this
isn't as simple as searching a database and spitting back a table of results
since there's business logic involved.
 
Thanks. That sort of makes sense. :)

So I take it that I can't place a button that when clicked will process a
chunk of code unless I get real complicated?

I can get along with doing the processing on the print page simply by
checking the form results and performing my calculations but I was hoping to
do it before the form was submitted - it is submitted before it is printed.
 
Post to a hidden page the run your calculation, if the calculation passes, then go the to the next
page or if it fails, return the user to the form. You can also do this on the final page as well.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
Thanks for the input. I added code to the page that prints the form that
shows if the product is under warranty. That is a partial solution.

I would like to make the calculation on the form where we submit the
information so that we can recommend the options to the customer if the
equipment is out of warranty. I thought about adding another form button and
having it do the calculations and perhaps open a dialog box with the results
or insert them in the form...
 
You indicated the date is part of the SN
- as in say XXXX04012006YYYY
If it is consistent in how the date is part of the SN you can easily parse out the date part of the SN and check it for expiration
Post a sample serial # and what the date means (i.e. date of purchase or date of expiration of warranty)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Thanks for the input. I added code to the page that prints the form that
| shows if the product is under warranty. That is a partial solution.
|
| I would like to make the calculation on the form where we submit the
| information so that we can recommend the options to the customer if the
| equipment is out of warranty. I thought about adding another form button and
| having it do the calculations and perhaps open a dialog box with the results
| or insert them in the form...
|
| --
| Dave Lagergren
| Manager - Data Applications
| Wireless Management, Inc
| Specializing in cellular wireless applications
|
|
| "Thomas A. Rowe" wrote:
|
| > Post to a hidden page the run your calculation, if the calculation passes, then go the to the next
| > page or if it fails, return the user to the form. You can also do this on the final page as well.
| >
| > --
| > ==============================================
| > Thomas A. Rowe
| > Microsoft MVP - FrontPage
| >
| > http://www.Ecom-Data.com
| > ==============================================
| >
| >
| > | > > Thanks. That sort of makes sense. :)
| > >
| > > So I take it that I can't place a button that when clicked will process a
| > > chunk of code unless I get real complicated?
| > >
| > > I can get along with doing the processing on the print page simply by
| > > checking the form results and performing my calculations but I was hoping to
| > > do it before the form was submitted - it is submitted before it is printed.
| > >
| > > --
| > > Dave Lagergren
| > > Manager - Data Applications
| > > Wireless Management, Inc
| > > Specializing in cellular wireless applications
| > >
| > >
| > > "Mark Fitzpatrick" wrote:
| > >
| > >> Dave,
| > >> You'll need to do some custom coding on the server. Classic asp is a
| > >> little trickier than ASP.Net. If it's classing ASP you'll need to have an
| > >> extra hidden form field that let's you know when you're posting back to the
| > >> page. Then in ASP you can see if there is such a hidden field and if there
| > >> is, it means that a button has been clicked and you're posting to the page
| > >> (if it isn't it means that no form has been submitted and you don't need to
| > >> process). Then you have to talk to a database somewhere and get some sort of
| > >> result after performing your business logic to determine warranty. You'll
| > >> have to perform another operation based upon the results, whether it's
| > >> printing out additional code to let them know it's not under warrenty and
| > >> what they should do, or that it is under warrenty and what to do next.
| > >>
| > >> Basically, you're going to have to do some coding by hand since this
| > >> isn't as simple as searching a database and spitting back a table of results
| > >> since there's business logic involved.
| > >>
| > >>
| > >> --
| > >> Hope this helps,
| > >> Mark Fitzpatrick
| > >> Former Microsoft FrontPage MVP 199?-2006
| > >>
| > >>
| > >> | > >> >I have a form that is filled out online. One of the fields is the serial
| > >> > number which is encoded to include the date. This is used to determine if
| > >> > the unit is under warranty or not.
| > >> >
| > >> > How can I put in a push button that will run a routine to check the serial
| > >> > number and see if it is under warranty? I can generate the code for
| > >> > validation just fine, I simply can't figure out how to execute the code on
| > >> > a
| > >> > button push. I would prefer to have the code inline, not on a separate
| > >> > page.
| > >> >
| > >> > I am using asp pages.
| > >> > --
| > >> > Dave Lagergren
| > >> > Manager - Data Applications
| > >> > Wireless Management, Inc
| > >> > Specializing in cellular wireless applications
| > >>
| > >>
| > >>
| >
| >
| >
 
The serial number is in the format 364VEM1234
where the 364 is ignored, the E is the year (A- 2000, B- 2001, etc) the M is
the month where:

A B = Jan
C D = Feb
E F = Mar
G H = Apr
J K = May
L M = June
N P = July
Q R = August
S T = Sept
U V = Oct
W X = Nov
Y Z = Dec

I and O are not used.

I can parse the string and have set up a routine to check and see if it was
mfgd less than 12 months ago.

--
Dave Lagergren
Manager - Data Applications
Wireless Management, Inc
Specializing in cellular wireless applications


Stefan B Rusynko said:
You indicated the date is part of the SN
- as in say XXXX04012006YYYY
If it is consistent in how the date is part of the SN you can easily parse out the date part of the SN and check it for expiration
Post a sample serial # and what the date means (i.e. date of purchase or date of expiration of warranty)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Thanks for the input. I added code to the page that prints the form that
| shows if the product is under warranty. That is a partial solution.
|
| I would like to make the calculation on the form where we submit the
| information so that we can recommend the options to the customer if the
| equipment is out of warranty. I thought about adding another form button and
| having it do the calculations and perhaps open a dialog box with the results
| or insert them in the form...
|
| --
| Dave Lagergren
| Manager - Data Applications
| Wireless Management, Inc
| Specializing in cellular wireless applications
|
|
| "Thomas A. Rowe" wrote:
|
| > Post to a hidden page the run your calculation, if the calculation passes, then go the to the next
| > page or if it fails, return the user to the form. You can also do this on the final page as well.
| >
| > --
| > ==============================================
| > Thomas A. Rowe
| > Microsoft MVP - FrontPage
| >
| > http://www.Ecom-Data.com
| > ==============================================
| >
| >
| > | > > Thanks. That sort of makes sense. :)
| > >
| > > So I take it that I can't place a button that when clicked will process a
| > > chunk of code unless I get real complicated?
| > >
| > > I can get along with doing the processing on the print page simply by
| > > checking the form results and performing my calculations but I was hoping to
| > > do it before the form was submitted - it is submitted before it is printed.
| > >
| > > --
| > > Dave Lagergren
| > > Manager - Data Applications
| > > Wireless Management, Inc
| > > Specializing in cellular wireless applications
| > >
| > >
| > > "Mark Fitzpatrick" wrote:
| > >
| > >> Dave,
| > >> You'll need to do some custom coding on the server. Classic asp is a
| > >> little trickier than ASP.Net. If it's classing ASP you'll need to have an
| > >> extra hidden form field that let's you know when you're posting back to the
| > >> page. Then in ASP you can see if there is such a hidden field and if there
| > >> is, it means that a button has been clicked and you're posting to the page
| > >> (if it isn't it means that no form has been submitted and you don't need to
| > >> process). Then you have to talk to a database somewhere and get some sort of
| > >> result after performing your business logic to determine warranty. You'll
| > >> have to perform another operation based upon the results, whether it's
| > >> printing out additional code to let them know it's not under warrenty and
| > >> what they should do, or that it is under warrenty and what to do next.
| > >>
| > >> Basically, you're going to have to do some coding by hand since this
| > >> isn't as simple as searching a database and spitting back a table of results
| > >> since there's business logic involved.
| > >>
| > >>
| > >> --
| > >> Hope this helps,
| > >> Mark Fitzpatrick
| > >> Former Microsoft FrontPage MVP 199?-2006
| > >>
| > >>
| > >> | > >> >I have a form that is filled out online. One of the fields is the serial
| > >> > number which is encoded to include the date. This is used to determine if
| > >> > the unit is under warranty or not.
| > >> >
| > >> > How can I put in a push button that will run a routine to check the serial
| > >> > number and see if it is under warranty? I can generate the code for
| > >> > validation just fine, I simply can't figure out how to execute the code on
| > >> > a
| > >> > button push. I would prefer to have the code inline, not on a separate
| > >> > page.
| > >> >
| > >> > I am using asp pages.
| > >> > --
| > >> > Dave Lagergren
| > >> > Manager - Data Applications
| > >> > Wireless Management, Inc
| > >> > Specializing in cellular wireless applications
| > >>
| > >>
| > >>
| >
| >
| >
 
From your Example SN

strSN = "364VEM1234"

To parse out the "EM" part from the string "364VEM1234" you are looking for the 5th & 6th character so use:
Mid(string, start[, length]) to get the 2 letters

IF Len(strSN)>7 THEN
strYr = Ucase(mid(strSN, 5,1)) 'gets "E" in the above SN
strMo = Ucase(mid(strSN, 6,1)) 'gets "M" in the above SN
ELSE
' code for invalid SN (SN is too short) here
END IF

Then use the Asc(string) on the Year code to convert from Alpha (ascii) to numeric values where 65 = A, 66= B, etc

intYr = 2000+(Asc(strYr)-65) ' gets 2005 for an E

And probably use a Case Select to get the Month (as a number) from the letter in strMo

Select Case strMo
Case "A", "B"
intMo = 1
Case "C", "D"
intMo = 2
Case "E", "F"
intMo = 3
Case "G", "H"
intMo = 4
Case "J", "K"
codeMo = 5
Case "L", "M"
intMo = 6
Case "N", "P"
intMo = 7
Case "Q", "R"
intMo = 8
Case "S", "T"
intMo = 9
Case "U", "V"
intMo = 10
Case "W", "X"
intMo = 11
Case "Y", "Z"
intMo = 12
Case Else
intMo = 0 ' default for a bad letter
End select ' would give you 6 (Jun) for an "M" in strMo

This now gives you a possible date to compare to as:

strMfgDate = "1" & "/" intMo & "/" intYr ' would give you "1/6/2005"

IF IsDate(strMfgDate) THEN 'make sure we have a valid date
dateMFG = Cdate(strMfgDate)
dateExpire = DateAdd("m",1,dateMFG) ' get 1st day of month after actual MFG month
dateNow = Cdate("1" & "/" & Month(Date()) & "/" & Year(Date())) 'set now to 1st day of month
IF DateDiff("yyyy",dateExpire,dateNow)>1 THEN
strStatus="Warranty Expired"
ELSE
strStatus="Warranty Valid"
END IF
ELSE
'code for a bad date code here when results are not a valid date
END IF




_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| The serial number is in the format 364VEM1234
| where the 364 is ignored, the E is the year (A- 2000, B- 2001, etc) the M is
| the month where:
|
| A B = Jan
| C D = Feb
| E F = Mar
| G H = Apr
| J K = May
| L M = June
| N P = July
| Q R = August
| S T = Sept
| U V = Oct
| W X = Nov
| Y Z = Dec
|
| I and O are not used.
|
| I can parse the string and have set up a routine to check and see if it was
| mfgd less than 12 months ago.
|
| --
| Dave Lagergren
| Manager - Data Applications
| Wireless Management, Inc
| Specializing in cellular wireless applications
|
|
| "Stefan B Rusynko" wrote:
|
| > You indicated the date is part of the SN
| > - as in say XXXX04012006YYYY
| > If it is consistent in how the date is part of the SN you can easily parse out the date part of the SN and check it for
expiration
| > Post a sample serial # and what the date means (i.e. date of purchase or date of expiration of warranty)
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | > | Thanks for the input. I added code to the page that prints the form that
| > | shows if the product is under warranty. That is a partial solution.
| > |
| > | I would like to make the calculation on the form where we submit the
| > | information so that we can recommend the options to the customer if the
| > | equipment is out of warranty. I thought about adding another form button and
| > | having it do the calculations and perhaps open a dialog box with the results
| > | or insert them in the form...
| > |
| > | --
| > | Dave Lagergren
| > | Manager - Data Applications
| > | Wireless Management, Inc
| > | Specializing in cellular wireless applications
| > |
| > |
| > | "Thomas A. Rowe" wrote:
| > |
| > | > Post to a hidden page the run your calculation, if the calculation passes, then go the to the next
| > | > page or if it fails, return the user to the form. You can also do this on the final page as well.
| > | >
| > | > --
| > | > ==============================================
| > | > Thomas A. Rowe
| > | > Microsoft MVP - FrontPage
| > | >
| > | > http://www.Ecom-Data.com
| > | > ==============================================
| > | >
| > | >
| > | > | > | > > Thanks. That sort of makes sense. :)
| > | > >
| > | > > So I take it that I can't place a button that when clicked will process a
| > | > > chunk of code unless I get real complicated?
| > | > >
| > | > > I can get along with doing the processing on the print page simply by
| > | > > checking the form results and performing my calculations but I was hoping to
| > | > > do it before the form was submitted - it is submitted before it is printed.
| > | > >
| > | > > --
| > | > > Dave Lagergren
| > | > > Manager - Data Applications
| > | > > Wireless Management, Inc
| > | > > Specializing in cellular wireless applications
| > | > >
| > | > >
| > | > > "Mark Fitzpatrick" wrote:
| > | > >
| > | > >> Dave,
| > | > >> You'll need to do some custom coding on the server. Classic asp is a
| > | > >> little trickier than ASP.Net. If it's classing ASP you'll need to have an
| > | > >> extra hidden form field that let's you know when you're posting back to the
| > | > >> page. Then in ASP you can see if there is such a hidden field and if there
| > | > >> is, it means that a button has been clicked and you're posting to the page
| > | > >> (if it isn't it means that no form has been submitted and you don't need to
| > | > >> process). Then you have to talk to a database somewhere and get some sort of
| > | > >> result after performing your business logic to determine warranty. You'll
| > | > >> have to perform another operation based upon the results, whether it's
| > | > >> printing out additional code to let them know it's not under warrenty and
| > | > >> what they should do, or that it is under warrenty and what to do next.
| > | > >>
| > | > >> Basically, you're going to have to do some coding by hand since this
| > | > >> isn't as simple as searching a database and spitting back a table of results
| > | > >> since there's business logic involved.
| > | > >>
| > | > >>
| > | > >> --
| > | > >> Hope this helps,
| > | > >> Mark Fitzpatrick
| > | > >> Former Microsoft FrontPage MVP 199?-2006
| > | > >>
| > | > >>
| > | > >> | > | > >> >I have a form that is filled out online. One of the fields is the serial
| > | > >> > number which is encoded to include the date. This is used to determine if
| > | > >> > the unit is under warranty or not.
| > | > >> >
| > | > >> > How can I put in a push button that will run a routine to check the serial
| > | > >> > number and see if it is under warranty? I can generate the code for
| > | > >> > validation just fine, I simply can't figure out how to execute the code on
| > | > >> > a
| > | > >> > button push. I would prefer to have the code inline, not on a separate
| > | > >> > page.
| > | > >> >
| > | > >> > I am using asp pages.
| > | > >> > --
| > | > >> > Dave Lagergren
| > | > >> > Manager - Data Applications
| > | > >> > Wireless Management, Inc
| > | > >> > Specializing in cellular wireless applications
| > | > >>
| > | > >>
| > | > >>
| > | >
| > | >
| > | >
| >
| >
| >
 
Back
Top