Age Function / Validation

0
August 17, 2011

Hi,

I asked a question yesterday and i thought i got the answer, but it is not working properly.. i am new to asp, so please can you help.

But since yesterday i have found that i need something slightly different...

i need to work out the customers age at inception date ie

So i need a function that will work out their age based on the inception date given and their DOB i.e - if the inception date is 28/06/2005 and their date of birth is 01/01/1972 it will tell me their age, age is needed because this is what i send in the xml...

my form is below.... if you want my xml page i will send that aswell..

<html>

      <head>

            <title> Healthcare Quotations</title>            

            <script language="JavaScript" type="text/javascript">

if(document.all && !document.getElementById) {

    document.getElementById = function(id) {

         return document.all[id];

    }

}

<!--

function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(p

arseInt(ap

pVersion)=

=4)) {

    document.MM_pgW=innerWidth

; document.MM_pgH=innerHeigh

t; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_p

gW || innerHeight!=document.MM_p

gH) location.reload();

}

MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&p

arent.fram

es.length)

{

    d=parent.frames[n.substrin

g(p+1)].do

cument; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;

i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.

layers.len

gth;i++) x=MM_findObj(n,d.layers[i]

.document)

;

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_setTextOfLayer(objName,

x,newText)

{ //v4.01

  if ((obj=MM_findObj(objName))

!=null) with (obj)

    if (document.layers) {document.write(unescape(n

ewText)); document.close();}

    else innerHTML = unescape(newText);

}

//-->

</script>

            <style>

      #sub1, #sub2

      {

      position: absolute;

      left: 429px;

      visibility: hidden;

      z-index: 2;

      width: 176px;

      }

.style3 {

      font-size: 12px;

      font-family: Verdana, Arial, Helvetica, sans-serif;

}

.style4 {font-family: Verdana, Arial, Helvetica, sans-serif}

</style>

            <script language="JavaScript">

<!--

<!-- Begin

catnumber = 2

offset = 150

performOnchange = false

if (document.all) {

  docObj = "document.all."

  styleObj = ".style"

  } else {

  docObj = "document."

  styleObj = ""

}

function openselect(subcat) {

  popupselect = eval(docObj + subcat + styleObj)

  popupselect.visibility = "visible"

}

function closeselect(submenu,subcat

){

  popupselect = eval(docObj + subcat + styleObj)

  if (submenu.selectedIndex != 0) {

    popupselect.visibility = "hidden"

    numchoice = submenu.selectedIndex

    choice = submenu[numchoice].value

    quoteForm.subcategory.valu

e = choice

      CalcLivingCare()

    submenu.selectedIndex = 0

  }

}

function lock() {

  performOnchange = false

}

function unlock() {

  performOnchange = true

}

function CalcLivingCare() {

if (quoteForm.categoria.value

== "ageover") {

    quoteForm.subcategory2.val

ue = quoteForm.subcategory.valu

e * (4/10)}

  else

{

    quoteForm.subcategory2.val

ue = quoteForm.subcategory.valu

e * (1/10)}

}

function selectSub(cat) {

  for (i=1; i <= catnumber; i++) {

    subcat = "sub" + i

    popupselect = eval(docObj + subcat + styleObj)

    popupselect.visibility = "hidden"

  }

  if (performOnchange == true) {

    letsopen = "sub" + cat.selectedIndex

    if (letsopen == "sub0") {

      alert("No category selected")

      choice = "- subcategory -"

      quoteForm.subcategory.valu

e = choice

        quoteForm.subcategory2.val

ue = choice

      cat.focus()

      } else {

      openselect(letsopen)

      lock()

    }

  }

}

//  End -->

function MM_popupMsg(msg) { //v1.0

  alert(msg);

}

//-->

</script>

            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

      </head>

      <%

      dim cday

      dim cmonth

      cday = day(DATE)

      if len(cday) = 1 then

            cday = "0" &cday

      end if

      cmonth = month(DATE)

      if len(cmonth) = 1 then

            cmonth = "0" &cmonth

      end if

%>

      <body bgcolor="#ffffff">

            <form onsubmit="return check_form();" method="post" action="LifeLinePlusquote.

asp" name="quoteForm">

            <table width="97%" border="0" cellpadding="4" cellspacing="0">

                  <tr>

                        <td width="41%"><span class="style3">On your next Birthday will you be </span></td>

                        <td width="59%">

                              <div align="left">

                                    <span id="sub1"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="../../Images/helpPers

onal.gif" alt="Click for Information" width="20" height="20" align="absmiddle" class="rapid1" onclick="MM_popupMsg('Plea

se note that the maximum amount of cover in Lifeline Plus is £100,000 for clients below 60 and £50,000 for clients over 60.')"></font><select name="subageunder" onchange="closeselect(this

,'sub1')">

                                                <option selected value="0">Lifeline Sum Assured</option><% Dim counter

counter=1

for counter = 1 to 100 %><% Response.Write "<OPTION value="&CStr(counter*1000)

& ">" &CStr(counter*1000) & "</OPTION>" %><% NEXT %>

                                          </select> </span><span id="sub2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="../../Images/helpPers

onal.gif" alt="Click for Information" width="20" height="20" align="absmiddle" class="rapid1" onclick="MM_popupMsg('Plea

se note that the maximum amount of cover in Lifeline Plus is £100,000 for clients below 60 and £50,000 for clients over 60.')"></font><select name="subageover" onchange="closeselect(this

,'sub2')">

                                                <option selected value="">Lifeline Sum Assured</option><% Dim ccounter

ccounter= 1

for ccounter = 1 to 50 %><% Response.Write "<OPTION value="&CStr(ccounter*1000

) & ">" &CStr(ccounter*1000) & "</OPTION>" %><% NEXT %>

                                          </select> </span><select name="categoria" onmouseover="unlock()" onchange="selectSub(this)"

>

                                          <option value="" selected="selected">-- Age Attained --</option>

                                          <option value="ageunder">60 or Under?</option>

                                          <option value="ageover">Over 60?</option>

                                    </select> <br>

                              </div>

                        </td>

                  </tr>

                  <tr>

                        <td class="style3">What is your Age </td>

                        <td><input name="Ages" type="text" id="Ages" size="2" maxlength="2" /></td>

                  </tr>

            </table>

            <table width="97%" height="346" border="0" cellpadding="4" cellspacing="0">

                  <tr>

                        <td height="24"> </td>

                        <td> </td>

                        <td width="3%" rowspan="13"> </td>

                        <td width="2%" rowspan="13"> </td>

                  </tr>

                  <tr>

                        <td width="41%" height="24"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Post Code</font></td>

                        <td width="54%"><input name="postcode1" id="postcode1" size="4" maxlength="4"> <input name="postcode2" id="postcode2" size="4" maxlength="4"></td>

                  </tr>

                  <tr>

                        <td height="32"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Policy Type</font></td>

                        <td>

                              <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><select name="Products" size="1" multiple id="Products" style="BACKGROUND-COLOR: white">

                                                <option value="F+, FV" selected="selected">LifeLi

ne Plus</option>

                                          </select> </font></p>

                        </td>

                  </tr>

                  <tr>

                        <td height="30"><font face="Verdana" size="2">Inception Date</font></td>

                        <td><font size="3"><input name="dateStr2" size="1" maxlength="2" value="<%=cday%>"> / <input name="monthStr2" size="1" maxlength="2" value="<%=cmonth%>"> / <input name="yearStr2" size="4" maxlength="4" value="<%=year(DATE)%>"> </font></td>

                  </tr>

                  <tr>

                        <td><span class="style3">Your Lifeline Sum Assured </span></td>

                        <td><input name="subcategory" type="text" id="subcategory" size="5" maxlength="5" readonly="readonly"></td>

                  </tr>

                  <tr>

                        <td height="30" class="style3">Your Living Care Sum Assured</td>

                        <td valign="middle" class="style3">£ <input name="subcategory2" type="text" id="subcategory2" size="5" maxlength="5"></td>

                  </tr>

                  <tr>

                        <td height="30"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">D.O.B</font></

td>

                        <td><font size="3"><input name="dateStr1" size="1" maxlength="2" value="01"> / <input name="monthStr1" size="1" maxlength="2" value="01"> / <input name="yearStr1" size="4" maxlength="4" value="1900"> </font></td>

                  </tr>

                  <tr>

                    <td height="24"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Gender</font><

/td>

                    <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">

                      <select name="Gender" id="Gender">

                  <option selected="selected">Gender

</option>

                  <option value="M">Male</option>

                  <option value="F">Female</option>

                </select>

                    </font></td>

              </tr>

                  <tr>

                        <td height="32"> </td>

                        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">  </font></td>

                  </tr>

                  <tr>

                        <td colspan="2"> </td>

                  </tr>

                  <tr>

                        <td height="2"></td>

                  </tr>

            </table>

            <div align="center">

                  <br>

                  <input name="calcpremium" type="image" src="../../Images/calculat

e.gif" alt="Calculate your premium based on the information that you have entered" width="136" height="30" border="0"><br>

                  <br>

      </form><br>

      </body>

</html>

28

answers

Comments See all(0)

Add comment
0
August 17, 2011

This is the revised function....  try this when you get back in the morning.

Function getAge(strDOB, strInceptionDate)

Dim intMonth, intDay, intYear, intCurrentYear, intCurrentDay, intCurrentMonth, intAgeNextBirthday

Dim strBirthDayThisYear, strCurrentDate

intMonth = Month(strDOB)

If intMonth < 10 Then intMonth = "0" & intMonth

intDay = Day(strDOB)

If intDay < 10 Then intDay = "0" & intDay

intYear = Year(strDOB)

'get the current year from the NOW function

intCurrentYear = Year(strInceptionDate)

intCurrentDay = Day(strInceptionDate)

If intCurrentDay < 10 Then intCurrentDay = "0" & intCurrentDay

intCurrentMonth = Month(strInceptionDate)

If intCurrentMonth < 10 Then intCurrentMonth = "0" & intCurrentMonth

strBirthDayThisYear = intCurrentYear & intMonth & intDay 'yyyymmdd format

strCurrentDate = intCurrentYear & intCurrentMonth & intCurrentDay 'yyyymmdd format

If strBirthDayThisYear <= strCurrentDate Then

    intAgeNextBirthday = intCurrentYear - intYear 'if bday just passed this year

Else

    intAgeNextBirthday = intCurrentYear - intYear - 1 'if birthday is in future

End If

getAge = intAgeNextBirthday

End Function

0
August 17, 2011

the DateDiff function should work for you...

dim age

age = datediff("yyyy","1/1/1972"

,"6/28/200

5")

0
August 17, 2011

sorry, but could you elaborate

0
August 17, 2011

Sure, the DateDiff function is a built in vbs function. Details here:

http://msdn.microsoft.com/ library/de fault.asp? url=/libra ry/ en-us/s cript56/ht ml/vtorifu nctions.as p

and here:

http://msdn.microsoft.com/ library/de fault.asp? url=/libra ry/ en-us/s cript56/ht ml/vsfctda tediff.asp

0
August 17, 2011

ok, could you show me how to implement it within my code?

0
August 17, 2011

You pass an interval -- "year" in your case -- and a start date and an end date. DateDiff figures out the number of intervals between the dates. Intervals can be year, month, day, etc...

0
August 17, 2011

sure, one sec

0
August 17, 2011

Are you doing all calculations client-side? Or do you calc the age after submitting the form?

0
August 17, 2011

well im not sure which is best..... I have a fuction in my xml page, which is wrong, it is a function that works out your age next birthdate, which is what i thought was needed..... i really need it doing client side because i need the age to send in the soap envelope

0
August 17, 2011

@berkeleymorgan - i tried to help you out yesterday with calc Age at Next Birthday.

Now can you confirm what should be the age in the following? Also is the inception date entered by the user or is it the current date when the user is applying for the quote?

Scenario 1:

inception date = 28/06/2005

DOB = 01/01/1972

Age = ??

Scenario 2:

inception date = 28/06/2005

DOB = 28/12/1972

Age = ??

Scenario 3:

inception date = 28/06/2005

DOB = 28/06/1972

Age = ??

0
August 17, 2011

yes i know you did, and i thank you for your help..... I was informed that the quote was based on your age next birthday ( please remember i am conecting to a soap.dll that has been created to a delphi quotation package and i have based my question on how it was put to me

But it turns out that the quote is not based on that... it is based on your age at inception.. so if your birthday is 01/01/1972 you are 33 and it will send that down in the xml... but if your birthdate is today or after today - 15/08/1972 then I need to send down a 32.......

your code is fine and worked for what i asked...

I think its simpler than i explain..

I have inception date fields - which are defaulted to the current date....... the user can change this to a date within a month after the current date.... it wont give them a quote if they go over.

I have DOB fields which the user inputs

And i have a Age field which is blank..

i would like a calc that based on the inception date and date of birth given it will work out your age and put it into the ages field..

I dont have a problem sending the age down.

0
August 17, 2011

Here's an example:

<script>

function dateDiff(dType, date1, date2){

  divider = 1000;

    if(dType=="y") divider = 365*24*60*60*1000;

  return wholeNum(((new Date(date2))-(new Date(date1)))/divider);

}

function wholeNum(Num) {

      return Num.toString().substring(0

,Num.toStr

ing().last

IndexOf('.

'));

}

</script>

<form name="form1">

date1: <input type=text name="date1" value="01/01/1972"><br>

date2: <input type=text name="date2" value="06/28/2005"><br>

<input value="get age" type=button onclick="document.form1.ag

e.value=da

teDiff('y'

,document.

form1.date

1.value,do

cument.for

m1.date2.v

alue);"><b

r>

Age: <input type=text name="age"><br>

</form>

0
August 17, 2011

So, with my client-side example, you'll pass in the 2 dates and the "y" dType to the DateDiff function. It returns the number of years between the 2 dates. The wholeNum function then chops off the decimal portion of the years...

0
August 17, 2011

So pls confirm the following ages then

Scenario 1:

inception date = 28/06/2005

DOB = 01/01/1972

Age = 23 (23 years completed)

Scenario 2:

inception date = 28/06/2005

DOB = 28/12/1972

Age = 22 (22 years completed)

Scenario 3:

inception date = 28/06/2005

DOB = 28/06/1972

Age = 22 (turned 22 on inception date)

0
August 17, 2011

inception date = 28/06/2005

DOB = 01/01/1972

Age = 23 (23 years completed)

--- above.... should be 33

Scenario 2:

inception date = 28/06/2005

DOB = 28/12/1972

Age = 22 (22 years completed)

--- above.... should be 32

Scenario 3:

inception date = 28/06/2005

DOB = 28/06/1972

Age = 22 (turned 22 on inception date)

--- above..... should be 33

0
August 17, 2011

yup ... sorry my mistake...

I am modifying the function ... you will find that the variable names are from the old function ... dont get confused.

function getAge (strDOB, strInceptionDate)

Dim intMonth, intDay, intYear, intCurrentYear, intCurrentDay, intCurrentMonth, intAgeNextBirthday

Dim strBirthDayThisYear , strCurrentDate

intMonth = Month (strDOB)

intDay = Day (strDOB)

intYear = Year (strDOB)

get the current year from the NOW function

intCurrentYear = Year(strInceptionDate)

intCurrentDay = Day (strInceptionDate)

intCurrentMonth = Month (strInceptionDate)

strBirthDayThisYear = intCurrentYear & intMonth & intDay 'yyyymmdd format

strCurrentDate= intYear & intCurrentMonth & intCurrentDay 'yyyymmdd format

if  strBirthDayThisYear <= strCurrentDate Then

    intAgeNextBirthday = intCurrentYear - intYear 'if bday just passed this year

else

    intAgeNextBirthday = intCurrentYear - intYear -1 'if birthday is in future

end if

getAge  = intAgeNextBirthday

end function

0
August 17, 2011

I get an error saying - missing DOB

0
August 17, 2011

pls note that the function is same as the old one except this one accepts 2 parameters... so when you call the fcntion make sure you provide both parameters.

Now missing DOB is an error that cannot be because of the fcuntion as there is nothing like DOB in the function (there is strDOB but not DOB). So please open the page again in notepad or any other editor and goto the line where the error is and paste that line. Also for better resolution, paste the whole code instead.

0
August 17, 2011

if i use the function you gave yesterday it returns a quote = function getAge (strDOB)

Dim intMonth, intDay, intYear, intCurrentYear, intCurrentDay, intCurrentMonth, intAgeNextBirthday

Dim strBirthDayThisYear , strCurrentDate

intMonth = Month (strDOB)

intDay = Day (strDOB)

intYear = Year (strDOB)

'get the current year from the NOW function

intCurrentYear = Year(Now())

intCurrentDay = Day (Now())

intCurrentMonth = Month (Now())

strBirthDayThisYear = intCurrentYear & intMonth & intDay 'yyyymmdd format

strCurrentDate= intYear & intCurrentMonth & intCurrentDay 'yyyymmdd format

if  strBirthDayThisYear < strCurrentDate Then

    intAgeNextBirthday = intCurrentYear - intYear  'if bday just passed this year

else

    intAgeNextBirthday = intCurrentYear - intYear  - 1'if birthday is todya or in future

end if

getAge  = intAgeNextBirthday

end function

      %>

if i use the one you have just given it doesnt??

0
August 17, 2011

here is my xml page

<%

    Dim strPostcode

    Dim strProducts

    Dim strPolicyStartDate

    Dim strAges

      Dim strGender

    Dim strCover

      Dim intBand

    Dim strTerms

      Dim intCoverAmounts

      Dim strPost1, strPost2

      Dim objXML, objXMLHTTP

      Dim xmlPremiumRequest

      Dim dblNetPremium

      Dim strDOB

      strPost1 = Trim(Request.Form("postcod

e1"))

      strPost2 = Trim(Request.Form("postcod

e2"))

      strPostcode = strPost1 & " " & strPost2

      'strAges = Request.form("Ages")

      strGender = Request.form("Gender")

      strCover = Request.form("Cover")

      intBand = Request.form("Band")

      strTerms = Request.Form("Terms")

      intCoverAmounts = Request.Form("subcategory"

) & "," & Request.Form ("subcategory2")

      ' Get clients age, in years

      with request

            strDOB = .Form("dateStr1") & "/"

            strDOB = strDOB & .Form("monthStr1") & "/"

            strDOB = strDOB & .Form("yearStr1")

      end with

      ' intAge = datediff("yyyy", strDOB, date) incorrect

      'intAge = int(datediff("m",strDOB,No

w)/12)

      if (month(strDOB) = month(Now)) and (day(strDOB) > day(Now)) then

            'intAge = intAge - 1

      end if

      ' Done.

      'Response.Write Request.Form("alarmContrac

t")

      'if Request.Form("alarmContrac

t")="True"

then

            'strReferral= "Is the alarm under a maintenance contract with the installing company?YY"

      'end if

      'if Request.Form("alarmContrac

t")="" then

            'strReferral= "Is the alarm under a maintenance contract with the installing company?YN"

      'end if

      ' Which policies do we want a quote for, and how much?

            strProducts = Request.form("Products")

      'if strProducts = "S" then

            'intCoverAmounts = "15000"

      'else

            'intCoverAmounts = "0"

      'end if

      ' --------

      with request

            strPolicyStartDate = cint(.Form("dateStr2"))

            strPolicyStartDate = strPolicyStartDate & "/" & cint(.Form("monthStr2"))

            strPolicyStartDate = strPolicyStartDate & "/" & cint(.Form("yearStr2"))

      end with

      ' handling of dependents - finish

      strAges = getAge (strDOB) ''this will give you the calc next bday age

' Begin our XML / SOAP Stuff

      set objXML = Server.CreateObject("Msxml

2.DOMDocum

ent.4.0")

      set objXMLHTTP = Server.CreateObject("Msxml

2.XMLHTTP.

4.0")

' This will want changing after testing or any time a different DLL is required

      'Const SoapServer = "

http://10.1.100.249:8080/ xml/SOAPPr emium.dll/ soap/ ISOAP Premium

"   'forwarded using MS SOAP trace from andrews pc.

      Const SoapServer = "

http://10.1.100.6/xml/SOA PPremium.d ll/soap/IS OAPPremium

"

' Create our SOAP Envelope

      xmlPremiumRequest = "<?xml version=""1.0"" ?>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""

http://sc hemas.xmls oap.org/so ap/envelop e/

"" xmlns:xsi=""

http://www.w3. org/1999/X MLSchema-i nstance

"" xmlns:xsd=""

http://www.w3. org/1999/X MLSchema

""

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<SOAP-ENV:Body>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<m:GetPremium xmlns:m=""urn:soappremiumi

nt-ISOAPPr

emium"">"

      xmlPremiumRequest = xmlPremiumRequest & "<premium>" & vbCrLf

' Starts here really

      xmlPremiumRequest = xmlPremiumRequest & "<Alias>JECKYLL</Alias>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<CtrlMode>Q</CtrlMode>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Start>" & strPolicyStartDate & "</Start>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Inception>" & strPolicyStartDate & "</Inception>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Modifier>" & "</Modifier>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Renewal>" & "</Renewal>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<CommissionDate>" & strPolicyStartDate & "</CommissionDate>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Products>" & strProducts & "</Products>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Terms>M</Terms>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Cover>S</Cover>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<CoverAmounts>" & intCoverAmounts & "</CoverAmounts>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<PayMethod>D</PayMethod>"

& vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Agency>0</Agency>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Consultant>23228</Consul

tant>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Gender>" & strGender & "</Gender>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Smoker>N</Smoker>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Postcode>" & strPostcode & "</Postcode>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Ages>" & strAges & "</Ages>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<BuildAge>" & "</BuildAge>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Band>0</Band>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Declaration>" & "</Declaration>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Supplemental>" & "</Supplemental>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Vouchers>" & "</Vouchers>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<ReferralText>" & "</ReferralText>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<ErrorText></ErrorText>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<PolicyID>0</PolicyID>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<BaseAge>0</BaseAge>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Excess>0</Excess>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Term>24</Term>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Renewed>0</Renewed>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<PayFrequency>1</PayFrequ

ency>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Introducer>0</Introducer

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Drip>0</Drip>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Accidental>0</Accidental

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Discount>0</Discount>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<Loading>0</Loading>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<AnnPremium>0</AnnPremium

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<NetPremium>0</NetPremium

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<IPTax>0</IPTax>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<GrossPremium>0</GrossPre

mium>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<SalesCommission>0</Sales

Commission

>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<IntroducerFee>0</Introdu

cerFee>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<AgencyFee>0</AgencyFee>"

& vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "<ReqCommission>0</ReqComm

ission>" & vbCrLf

' And ends here.

      xmlPremiumRequest = xmlPremiumRequest & "</premium>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "</m:GetPremium>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "</SOAP-ENV:Body>" & vbCrLf

      xmlPremiumRequest = xmlPremiumRequest & "</SOAP-ENV:Envelope>"

'Response.Clear

'Response.Write "<html><body>"

'Response.Write xmlPremiumRequest

'Response.Write "</html></body>"

'Response.end

      ' That's all, folks.

      ' Now we send it:

      with objXMLHTTP

            .open "POST", SoapServer, false

            .setRequestHeader "SOAP", POST & " " & SoapServer & " HTTP/1.1"

            .setRequestHeader "MessageType", "CALL"

            .setRequestHeader "ContentType", "text/xml"

      end with

      objXMLHTTP.send xmlPremiumRequest

      ' Now we can receive and write the response

      ' This needs to be set to false

      objXML.async = False

      ' This too - returned SOAP envelope from the DLL will not be valid

      objXML.validateOnParse = false

      ' Now we can load it in

      objXML.loadXML (objXMLHTTP.responseXML.xm

l)

      ' Or if we want to load from a file....

      ' objXML.load ("c:\inetpub\wwwroot\xm

lsoap\pre

miumrespon

se.xml")

      ' Check to see if there was any kind of error before we go any further

      ' and then return exactly what that error was

      If objXML.parseError.errorCod

e <> 0 Then

            Response.Write "<b>" & "Error" & "</b>"

            Response.Write "<br>"

            Response.Write objXML.parseError.reason

      End If

      ' Test stuff

      'for each xmlnode in objXML.childnodes

            'Response.Write "<br>" & "Element: " & "<BR>"

            'Response.Write objXML.nodeName & ": " & objXML.text & "<BR>"

            'Response.Write objXML.text & "<br>"

      'next

      Set objList = objXML.getElementsByTagNam

e("*")

      ' Now we iterate through the list to populate

      ' our variables

      ' Initialise intCount, just in case...

      intCount = 0

dblNetPremium=0

dblAnnPremium=0

      For i = 0 to (objList.length - 1)

            If objList.item(i).nodeName = "NetPremium" Then

                  dblNetPremium = objList.item(i).text

                  intCount = intCount + 1

            End If

            If objList.item(i).nodeName = "AnnPremium" then

                  dblAnnPremium = formatnumber((objList.item

(i).text),

2)

                  intCount = intCount + 1

            End If

          If objList.item(i).nodeName = "IPTax" Then

                dblIPTax = objList.item(i).text

                intCount = intCount + 1

          End If

          If objList.item(i).nodeName = "GrossPremium" Then

                dblGrossPremium = formatnumber((objList.item

(i).text),

2)

                intCount = intCount + 1

          End If

            If (objList.item(i).nodename = "ErrorText") Then

                  strErrorText = objList.item(i).text

                  intCount = intCount + 1

            End If

            If (objList.item(i).nodename = "Start") Then

                  strStartDate = objList.item(i).text

                  intCount = intCount + 1

            End If

            ' If we have all values then we can exit this loop, saves time

            If intCount = "6" Then

                  Exit For

            End If

      Next

'response.write "data sent to CREATEPREMIUM(QUOTE)" & vbCrLf

'response.write vbCrLf

'response.write xmlPremiumRequest & vbCrLf

'response.write vbCrLf

'response.write "data returned from CREATEPREMIUM(QUOTE)" & vbCrLf

'response.write vbCrLf

'response.write objXML.xml & vbCrLf

'response.write vbCrLf

'Response.end

                  'End iteration

function getAge (strDOB, strInceptionDate)

Dim intMonth, intDay, intYear, intCurrentYear, intCurrentDay, intCurrentMonth, intAgeNextBirthday

Dim strBirthDayThisYear , strCurrentDate

intMonth = Month (strDOB)

intDay = Day (strDOB)

intYear = Year (strDOB)

'get the current year from the NOW function

intCurrentYear = Year(strInceptionDate)

intCurrentDay = Day (strInceptionDate)

intCurrentMonth = Month (strInceptionDate)

strBirthDayThisYear = intCurrentYear & intMonth & intDay 'yyyymmdd format

strCurrentDate= intYear & intCurrentMonth & intCurrentDay 'yyyymmdd format

if  strBirthDayThisYear <= strCurrentDate Then

    intAgeNextBirthday = intCurrentYear - intYear 'if bday just passed this year

else

    intAgeNextBirthday = intCurrentYear - intYear -1 'if birthday is in future

end if

getAge  = intAgeNextBirthday

end function

      %>

0
August 17, 2011

I guessed this ...

you are making a call to the function without passing the inception date. see below and replace the followig code

strAges = getAge (strDOB) ''this will give you the calc next bday age

with these 3 lines of code

Dim strInceptionDate

strInceptionDate = Request.Form ("dateStr2")  & "/" & Request.Form ("monthStr2")  & "/" & Request.Form ("yearStr2")

strAges = getAge (strDOB, strInceptionDate) ''this will give you the calc next bday age

0
August 17, 2011

it works - well it brings a quote back........ but if i do todays date as inception and birthdate to match ie 28/06/2005 and 28/06/1972 it brings back the quote as if you are 32 not 33?

0
August 17, 2011

can we leave this open till tomoz??.... i finish now and really need to shoot!!!

0
August 17, 2011

no worries... i'll get you an answer when you come back tomorrow. Cheers!

0
August 17, 2011

thanks a bunch...

0
August 17, 2011

This doesn't work???

' intAge = datediff("yyyy", strDOB, date)

Do you get an error? Did you try doing a response.write to make sure it doesn't work? Like this:

intAge = datediff("yyyy", strDOB, date)

response.write intAge

response.end

0
August 17, 2011

datediff between 20/9/2003 and 20/3/2004 will return 1 whereas in the above case it should return 0. And also datediff between 30/11/2003 and 03/03/2005 returns 2 where as it should return 1.

That is why the custom function.

0
August 17, 2011

Randeeps

This seems to work a treat so far, I am going to do some more tests and then i will award the points...

Related Questions

data type validation in c++

Hi guys, i&#39;m new in c++. Consider the c++ program below: include&lt;iostream.h&gt; main() { &#160; &#160; int age; &#160; &#160; char gender; &#160; &#160; cout &lt;&lt; &quot;Enter age:&quot;; &# Read More

Views

14

Votes

0

Answers

4

August 17, 2011

Server-Side validation in Ajax Modal Popup Extender

I&#39;ve searched through lots of information, and still haven&#39;t found any examples of how to perform server-side validation of a form that is displayed in an Ajax Modal Popup Window. &#160; Curre Read More

Views

22

Votes

0

Answers

18

August 17, 2011

Need validation of a date in my JS

I have a page of JavaScript (code is below) that is used on an insurance company Web site to validate form data and calculate the amount to be charged, which is then returned to my Web form. It also r Read More

Views

19

Votes

0

Answers

8

August 17, 2011

validation of empty fields

i am trying validation. if both the fields are empty, i need to display both the error images next to them. but it shows only one at a time. pl suggest. also is there way to do this in jquery? &lt;!DO Read More

Views

15

Votes

0

Answers

6

August 15, 2011

Upgrade to 3.0 fails, internal websites are down

After running the upgrade advisor, there appeared to be no errors, so I proceded with upgrading the sharepoint services to 3.0. &#160;I ran the configuration wizard and it errors out with the message Read More

Views

37

Votes

0

Answers

3

August 17, 2011

WSS 3.0 Upgrade Error - Failed to Register SharePoint Services

I am performing an in-place upgrade of a WSS 2.0 site to WSS 3.0. &#160;After installing WSS 3.0, I begin to run the configuration wizard. &#160;The wizard fails on step 5 with the following message: Read More

Views

37

Votes

0

Answers

11

August 17, 2011

Form Drop Down Selection Loop Hole

I&#39;ve created a dependent drop down menu labeled &quot;Maintenance Type&quot;. When a user selects number 5 which is listed NMR a drop down appears with 2 fields available The problem/loop hole is Read More

Views

35

Votes

0

Answers

1

August 17, 2011

Help getting javascript CAPTCHA to work?

I&#39;ve got a conference registration form I built in ColdFusion 8. I&#39;m using a javascript CAPTCHA solution supplied by the redoubtable hielo, here: http://www.experts-exchang e.com/We Read More

Views

48

Votes

0

Answers

3

August 17, 2011

get primarykey from insert

if i want primary key that in sert sion form this code how can i get it // Call Row Inserting event &#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;$bInsertRow = $inventoryhead-&gt; Read More

Views

55

Votes

0

Answers

3

August 15, 2011

XSLT parse error in Mozilla, but not in IE

I have some .xml files which are displayed using an xsl stylesheet. They display correctly in IE, but in Mozilla I get:&quot;Error loading stylesheet: Parsing an XSLT stylesheet failed.&quot; Anybody Read More

Views

39

Votes

0

Answers

8

August 15, 2011

PECL stats library.. How to install

I want to use the statistical functions in php. I installed pear and PECL but if I do this echo stats_cdf_t(4.541,3,1); // this is line 7 I get an error which says Fatal error: Call to undefined funct Read More

Views

29

Votes

0

Answers

3

August 16, 2011

Can't read 'POSTED' values in PHP webpage

Hello. Here is my problem. I installed a FRESH apache web server for windows (2.2.8) and PHP 5.2.5 PHP doe not pick up the values that were posted in the previous page. However, if I read the input st Read More

Views

628

Votes

0

Answers

14

August 16, 2011

This is the very first question

Hello guys! This is the first post in this site Read More

Views

2k

Votes

4

Answers

2

January 08, 2016

report values not showing up.

I have a crystal report which I pass a DataSet to using VB.NET. The report was working fine, but then I make some changes to the import query and now nothing shows up in the crystal report. Crystal do Read More

Views

1k

Votes

0

Answers

12

September 06, 2005

Event log doesn't overwrite as needed in SP4

Hello All, After upgrading from SP3 to SP4 on several Windows 2000 PRO machines everything looked fine, but from time to time applications can&#39;t write to the event log. When I try to view the appl Read More

Views

1k

Votes

0

Answers

9

May 11, 2003

"Failed to self-register XYZ.dll"

Hi there, I wrote a OLE-automation-server DLL in VB4.0. I use Installshield Express to install it as part of my program on the target computers. Now on some computers I get the message &quot;Failed to Read More

Views

2k

Votes

0

Answers

2

November 08, 1998

Please help understand these notes on image processing

Can someone please help me understand these lecture notes... On the right of the page; What does &quot;normalised by one notion of the area of a pixel&quot; mean? On the first formula for A, Is that a Read More

Views

1k

Votes

0

Answers

3

February 05, 2009

Can someone please explain this paragram on the chain rule in image processing

Please see the screenshot, How is 3133030 got from 10103322? Read More

Views

1k

Votes

0

Answers

1

January 05, 2009

AD on 2003

We have created an AD Domain on Windows 2000 Server with no problems. We just created an AD Domain on Windows 2003 and we&#39;re getting some weird problems. Both of these domains are behind firewalls Read More

Views

1k

Votes

0

Answers

15

May 11, 2003

ADDT ASP Upload Error " Type mismatch: 'tNG_isFileInsideBaseFolder' "

I am trying to create a simple insert record and upload image function on an ASP page built using Adobe Dreamweaver Developer Toolkit. I have done this many times before with no problem, however, i ha Read More

Views

1k

Votes

0

Answers

0

November 02, 2008