Solved

Why dosen't event 'onload' fire?

Posted on 2000-05-08
24
537 Views
Last Modified: 2012-05-04
Hello!

When calling a JavaScript function in the form onload and body onload. the function won't be called, WHY?

I have also tryed to call the Java function when running the VBScript but I don't know how to do this. By passing variables between the scripts.
Is it possible to call a JavaFunction from VBScipt? If, How to...?
      
      'some VBScript before this      %>
      <script LANGUAGE="JavaScript">
      var Datum=getCookie("Datum");
      </script>
      <%
      If Datum="" Then Datum = Date()
%>
<html>

<head>
<title>Test</title>
0
Comment
Question by:jannea
  • 9
  • 8
  • 5
  • +1
24 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 2791355
VBscript to Javascript is just the same as when you call javascript from javascript.

In the onLoad if you have a vbscript function you should put in
onLoad="vbscript:blah" because the standard (of most browsers) is javascript.

Good luck,
CJ
0
 
LVL 1

Author Comment

by:jannea
ID: 2791392
Thanks CJ!

<body  onload="FrmLoad(this.form)" topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >
Is a Java function so this is the reason that it won't be fired or?

And when tryin this:

      Datum=getCookie("Datum")'JavaScript
      If Datum="" Then Datum = Date()
I'll get Type missmatch, why?
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2791418
1. if FrmLoad is a javascript function it should be fired. If it is a VBfunction it should not be fired...easy as that (NOTE: it might also be that the function FrmLoad is written incorrectly!!

2. getCookie is a javascript function, the if statement is a vbscript statement. If these occur in their own scripting (ie, vbscript tag and javascript tag) then what you are now getting are 2 dates with a different format.
Try to get the right date format from the Datum.

btw, why are you using both vb and javascript?
0
 
LVL 1

Author Comment

by:jannea
ID: 2791444
Thanks!

1.) It is JavaScript, and it is nothng wrong with it. I have done it simple just to check that its fired:

function FrmLoad(form)
{
      alert("FrmLoad");
}

2.) So how is  should I write? (I am a beginer)

I use both coz of the event wont fire.

/Janne

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2791511
onload="FrmLoad(this.form)"

this.form is not valid there.
It is valid in a button or a form field.

try

onload="FrmLoad(document.myForm)"

where myForm is the name of the form
if the form does not have a name, try this:
onload="FrmLoad(document.forms[0])"

which takes the first form on the page

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2791520
Also you are mixing server side vbscript (asp) with client side javascript.

Use the response.getCookie or whatever it is called in asp.

If you have

<script LANGUAGE="JavaScript">
Datum=getCookie("Datum");
</script>

then a client side vbscript can access it like this:
<script LANGUAGE="VBScript">
If window.Datum="" Then window.Datum = Date()
</script>


Michel
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2791545
okay, the javascript function should show you a message with FrmLoad in it, right? If so, then it (indeed) is fired, if not...then there's something wrong with the parameter you send (which looked weird to me right away).

For the date:
I should say, first check if you HAVE a cookie, by alerting it's vaklue which you retrieved with getCookie().
Does it say the date?
if so, then just check the value.

if(Datum=="") Datum = Date()

with Datum being declared like

Datum = new Date();

BUT, since you retrieved a string out of the cookie, you hafta change it to a Date first. By use of the getUTCDay, getUTCDate, getUTCYear


Did that help any?
0
 
LVL 1

Author Comment

by:jannea
ID: 2791649
Michel,

Event:
Have try this without result:

<body  onload="FrmLoad(document.Add)" topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >

<form method="post" action="<% =Add %>" id="Add" name="Add" onload="FrmLoad(document.forms[0])" onsubmit="return VerOk(this)">

And...:
Error when trying to access the variable:

 Microsoft VBScript runtime error '800a01a8'

Object required: 'Window'

/Kassabok.asp, line 110

/Janne
 
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2791684
1. There is no such thing as onLoad in a form tag.
2. Do not reuse names and try to use names that are not possible reserved words.
3. Unless you need to access the form with DHTML in IE, drop the id

<body  onload="FrmLoad(document.AddForm)" topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >

<form method="post" action="<% =Add %>" name="AddForm" onsubmit="return VerOk(this)">

What does VerOk look like???

Perhaps time to show us the form AND the script

Michel
0
 
LVL 1

Author Comment

by:jannea
ID: 2791702
Michel,

Stil getting the error, OK here is my code:

<script LANGUAGE="JavaScript">
//*****  Janne, Copyright(c) SummaGruppen AB 2000  *****
//**Skriva & Hämta cookie
var datum=getCookie("Datum");
function setCookie(name1,value1)
{
      var today = new Date();
      var expires = new Date();
      expires.setTime(today.getTime() + 60*60*24*365*10000);
      document.cookie = name1 + "=" + value1 + "; expires=" + expires.toGMTString();
}

function getCookie(Name)
{          
      var search = Name + "="          
      if (document.cookie.length > 0)
            { // om de finns cookies                    
                  offset = document.cookie.indexOf(search)                    
                  if (offset != -1)
                        { // Om cookien finns                            
                              offset += search.length  // Index på början av värdet
                              end = document.cookie.indexOf(";", offset) // Index på slutet av värdet
                              if (end == -1)
                              end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))                    
                        }
            }
}
//**Skall köras när formuläret laddas.
function FrmLoad(form)
{
      alert("FrmLoad");
      form.txtDatum.value=getCookie("Datum");
      //forms.elements[0].focus();
}

//Kollar momssats
function GetMoms(ctl)
{
      var str1 = "" + ctl.valueselected
      alert("str1=" + str1);
      var i = str1.indexOf("%");
      alert("i=" + i);
      //if (i=-1) return(0.2);//Ej hittat %
      var str2 = str1.substr(i-2, 2);
      i=parseint(str2)
      return(i);
}

function DateOK(ctl)
{
      //The format should be yyyy-mm-dd
      var OK = false
      var InDate = "" + ctl.value;
      var MaxDate = getCookie("MinDate")//Not before this date
      var MaxDate = getCookie("MaxDate")//Not after this date
      //CODE PLS
      return(i);
}
//**Beräknar momsen och belopp exkl. moms.
function BerMoms(form)
{
      isAmt(form.txtBelInkl,true);
      form.txtBelMoms.value=form.txtBelInkl.value*0.2;
      isAmt(form.txtBelMoms,true);
      form.txtBel1Exkl.value=form.txtBelInkl.value - form.txtBelMoms.value;
      isAmt(form.txtBel1Exkl,true);
      //alert(GetMoms(form.cmbKBelMoms))
}
//**Kolla att endast tal
function isAmt(field,done) {
   tstr=""+field.value;
   OK = true;
   nofPoints = 0;
   for (var i=0;i<tstr.length;i++) {
      if ('0123456789.'.indexOf(tstr.charAt(i)) ==-1) {
         if (done!=true) alert('Endast siffror och punkt (.) som decimalavgränsare, negativa tal är ej tillåtna.');
         OK=false;
         break;
      }
      else if (tstr.charAt(i)=='.') nofPoints++;
      if (nofPoints > 1) {
         if (done!=true) alert('Endast EN punkt (.) som decimalavgränsare.');
         OK=false;
         break;          
      }
   }
   if (!OK) {
      if (i>0) field.value=tstr.substring(0,i);
      else field.value ='';
   }
   else if (done) { //Formatera textfält med 2 decimaler
      dotPos = tstr.indexOf('.')
      decimals = tstr.substring(dotPos+1)    
      if (nofPoints > 0) {
         if (decimals.length < 2) {
            field.value += '00'.substring(0,2-decimals.length);
             
         }
         else field.value = tstr.substring(0,dotPos) + "" + tstr.substring(dotPos,dotPos+3)    
      }
      else field.value += '.00';
   }
      //Returnera summan i textfält
      return field.value;
}



//**Öppna nytt fönster
function getWin(url,W,H)
{
      var s='location=no,scrollbars=yes,toolbar=no,width=' + W + ',height=' + H;
      window.open(url,'_blank',s);
}


//**Skapa SIE.
function getSIE(url)
{
      alert("Denna funktion är ej klar ännu.");
}


//**Kolla om kontonummer är markerat
function KontoOK(ctl)
{

      if (ctl.selectedIndex ==0)
      //if (ctl.value.indexOf("<") + "" != "-1")
            {
                  alert("Du måste fylla i ett konto först.")
                  ctl.focus()
                  return false;
            }
      else return true;
}

//**Sätta Ing. eller Utg. momskonto berene på Inkomst/Utgift
function getIngUtgMoms(form,v)
{
      var i = 0
      if (v=="Ut") i=3;
      form.cmbKBelMoms.selectedIndex = i;
}


//**Radera senaste verifikat.
function Radera(VerNr)
{
     if (VerNr == 0)
        {
           alert("Det finns inget registrerat verifikat att radera.");
           return false;
          }
      var b = window.confirm ("Är det OK att radera det senast registrerade verifikatet (Nummer " + VerNr + ") ?");
      return  b;
}


//Kolla att verifikat är rätt ifyllt.
function VerOk(form)
{
      var b = false
      var newDateObj = new Date("DFGDF")
//Hämta belopp från textfälten
      var BelInkl = isAmt(form.txtBelInkl,true);
      var belM = isAmt(form.txtBelMoms,true);
      var bel1 = isAmt(form.txtBel1Exkl,true);
      var bel2 = isAmt(form.txtBel2Exkl,true);
      var bel3 = isAmt(form.txtBel3Exkl,true);
//Kolla att belopp inkl. moms är ifyllt
    if (BelInkl == "" || BelInkl == null || BelInkl < 0.01)
            {
                  alert("Du måste fylla i beloppet inkl. moms.")
                  form.txtBelInkl.focus()
                  return false;
            }
//Kolla att KONTO för belopp inkl. moms är ifyllt
      b=KontoOK(form.cmbKBelInkl)
      if (b != true)return false;
//Kolla om verifikattext är ifylld.
    if (form.txtText.value == "" || form.txtText.value == null )
            {
                  alert("Du måste fylla i en verifikatiostext.")
                  form.txtText.focus()
                  return false;
            }
//Kolla att konto ifyllt om momsbelopp ifyllt.
      b=true
      //if (belM>0) b=KontoOK(form.cmbKBelMoms)      
      if (b != true )return false;
//Kolla att KONTO för belopp1 är ifyllt om belopp1 >0.
      b=true
      if (bel1>0) b=KontoOK(form.cmbBel1Exkl)      
      if (b != true )return false;
//Kolla att KONTO för belopp2 är ifyllt om belopp2 >0.
      b=true
      if (bel2>0) b=KontoOK(form.cmbBel2Exkl)      
      if (b != true )return false;
//Kolla att KONTO för belopp3 är ifyllt om belopp3 >0.
      b=true
      if (bel3>0) b=KontoOK(form.cmbBel3Exkl)      
      if (b != true )return false;
//Kolla om verifikatet balanserar
      var diff = BelInkl - belM - bel1 - bel2 - bel3;
      if (diff<0) diff=diff*-1;//Ev teckenvända
      if (diff != 0)
            {
                  alert("Verifikatet balanserar inte, det diffar på " + diff + " Kr")
                  form.txtBel1Exkl.focus()
                  return false;
            }
//Har nu klarat alla tester.
      setCookie("Datum",form.txtDatum.value);
      return true;
}

</script>
<!--#Include File = "_Private\Inc\Init.asp"-->
<%

Sub TeckenVnd(KundID, VerNr)
'Teckenvända belopp
      SQL = "UPDATE Kassabok_Ver SET Kassabok_Ver.Belopp = [Kassabok_Ver]![Belopp]*-1 " & _
        "WHERE (((Kassabok_Ver.VerNr)=" & VerNr & "));"
      Set Rst = GetRsKassabok(SQL , KundID)
      'Rst.Close: et Rst = Nothing
End Sub
'Radera senaste verifikat.      
      s = "" & Request.QueryString("DelVer")
      If s <> "" Then
            Set Rs = GetRsKassabok("DELETE * FROM Kassabok_Ver WHERE VerNr = " & s , Session("KID"))
      End if
'Lägga till verifikat
      VerNr = "" & Request.QueryString("AddVer")
      If VerNr <> "" Then
            D = Request.Form("txtDatum")
            D = "#" & DatePart("m", D) & _
              "-" & DatePart("d", D) & "-" & _
              DatePart("yyyy", D) & "#"
            T = Request.Form("txtText")
            If Request.Form("InUt")="Ut" Then bUt = True
            SQLInkl = "INSERT INTO Kassabok_Ver ( VerNr, Datum, [Text], KontoNr, Belopp ) " & _
              "SELECT " & VerNr & " , " & D & ", '" & T & _
              "', '" & left(Request.Form("cmbKBelInkl"),4) & "', " & _
              Request.Form("txtBelInkl") & ";"
            If bUt Then 'Infoga belopp inkl. moms teckenvänt
                  Set Rst = GetRsKassabok(SQLInkl , Session("KID"))
                  Call TeckenVnd (Session("KID"), VerNr)
            End If
            'Infoga momsbelopp och motkonteringsrader.
            For X = 0 to 3
                  bel=0
                  Select case X
                    Case 0: bel=Request.Form("txtBelMoms"):K = left(Request.Form("cmbKBelMoms"),4)
                    Case 1: bel=Request.Form("txtBel1Exkl"):K = left(Request.Form("cmbBel1Exkl"),4)
                    Case 2: bel=Request.Form("txtBel2Exkl"):K = left(Request.Form("cmbBel2Exkl"),4)
                    Case 3: bel=Request.Form("txtBel3Exkl"):K = left(Request.Form("cmbBel3Exkl"),4)
                  End select
                  'bel=val(bel)
                  If Bel > 0 Then 'Om belopp i textfält
                        'Infoga belopp exkl. moms.
                        SQL = "INSERT INTO Kassabok_Ver ( VerNr, Datum, [Text], KontoNr, Belopp ) " & _
                          "SELECT " & VerNr & " , " & D & ", '" & T & _
                          "', '" & K & "', " & Bel & ";"
                        Set Rst = GetRsKassabok(SQL , Session("KID"))
                  End if
            Next
            If not bUt Then 'Infoga belopp inkl. moms EJ teckenvänt
                  Call TeckenVnd (Session("KID"), VerNr)
                  Set Rst = GetRsKassabok(SQLInkl , Session("KID"))
            end if
            'Rst.Close: Set Rst = Nothing
      End if
'Hämta kontoplan till combo.
      Set Rs = GetRsKassabok("Q_GetKpl", Session("KID"))
      if not rs.BOF and not rs.EOF Then
            Rs.Movefirst
            Do Until Rs.EOF
                  sK = sK & "<option>" & rs(0) & "</option>" & vbCrLf
                  If rs("Moms") Then sM = sM & "<option>" & rs(0) & "</option>" & vbCrLf
                  Rs.MoveNext
            Loop
      End if
'Hämta verifikat i kassboken
      Set Rs = GetRsKassabok("Q_GetKassaboks_Ver", Session("KID"))
      'Rs.Refresh
      'Set obj = Server.CreateObject("wwwsumma.wwwdllcls")
      MaxVer = 0
      if not rs.BOF and not rs.EOF Then
            Rs.Movefirst: MaxVer = rs("VerNr")
            Do Until Rs.EOF
                  A = "left"
                  For X = 0 to 3
                        Select Case X
                              Case 0: S = "<a href=javascript:getWin('http://www.summagruppen.se/KassaVer.asp?ID=" & _
                                  rs("VerNr") & "&KID=" & Session("KID") & "',400,270)>" & rs("VerNr") & "</a>"
                              Case 1: s = "" & rs("Datum")
                              Case 2: s = "" & rs("FText")
                              Case 3: A="right": s = Formatnumber("" & rs("Belopp") , 2)
                        End Select
                        sTab = sTab & "      <td valign='middle' align='" & A & "' " & _
                          "height='15' bgcolor='#FFFFFF'><small><small><small>" & vbCrLf & _
                            "        <font face='Verdana'>" & s & "</font></small></small></small></td>" & vbCrLf
                  Next
                  sTab = "    <tr>" & sTab & "</tr>" & vbCrLf
                  Rs.MoveNext
            Loop
            Del ="http://www.summagruppen.se/inloggad.asp?ID=" & Session("KID") & "&ToDo=Kassabok&DelVer=" & MaxVer
      End if
      Add ="http://www.summagruppen.se/inloggad.asp?ID=" & Session("KID") & "&ToDo=Kassabok&AddVer=" & MaxVer + 1
      Rpt = "<a href=javascript:getWin('http://www.summagruppen.se/kassalage.asp?KID=" & Session("KID") & "',540,480)>Lägesrapport</a>"
      SIE = "<a href=javascript:getSIE('http://www.summagruppen.se/kassasie.asp?KID=" & Session("KID") & "')>SIE-Fil</a>"
      sKalk = "<a href=javascript:getWin('http://www.summagruppen.se/kalkylatorn.htm',325,185)>Kalkylatorn</a>"
'Hämta uppgifter från tabellen 'Kundinfo'
      Set rs = GetRsKassabok("Q_Kundinfo", Session("KID"))
      if rs.BOF and rs.EOF Then
      else
            sMail = "" & rs("HandledareMail") & "?subject=Kassaboken - " & rs("FtgNamn")
            sMail = Server.HTMLEncode(sMail)
            'sMail = Server.URLEncode(sMail)
            sHandledare = "" & rs("Handledare")
      end if
      sHandledare = "Mejla min kontakt <a href='mailto:" & sMail & "'>" & sHandledare & "</a>"
      
      Rs.Close: Set Rs = Nothing
      'Datum=getCookie("Datum")
      If window.Datum="" Then window.Datum = Date()
%>
<html>

<head>
<title>Kassabok</title>
</head>

<body  onload="FrmLoad(document.AddForm)" topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >

<form method="post" action="<% =Add %>" name="AddForm" onsubmit="return VerOk(this)">
  <table border="0" width="391" height="160">
    <tr>
      <td valign="middle" align="left" width="419" height="26" bgcolor="#FFFFFF" colspan="3"><div
      align="center"><center><p><font face="Verdana"><small><small><small><% =sHandledare %> &nbsp; <% =Rpt %> &nbsp; <% =sKalk %> &nbsp; <% =SIE %></small></small></small></font></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Verifikationsdatum:</font></small></small></small></td>
      <td valign="middle" align="right" width="93" height="26" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><input type="text"
      name="txtDatum" size="9" value="<% = Datum %>"></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><strong>Verifikationsnr:</strong> <strong><font color="#0000FF"><% =(MaxVer + 1) %></font></strong></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="19" bgcolor="#FFFFFF"><font
      face="Verdana">
      <input type="radio" onclick="return getIngUtgMoms(this.form,'Ut')" value="Ut"
      name="InUt"><small><small><small>Uttag</small></small></small>
      <input type="radio" onclick="return getIngUtgMoms(this.form,'In')" value="In" name="InUt" checked><small><small><small>Insättning</small></small></small></font></td>
      <td valign="middle" align="center" width="93" height="19" bgcolor="#FFFFFF"><div
      align="left"><p><font face="Verdana"><small><small><small><input type="text" value="0.00"
      onKeyUp="return isAmt(this)" onblur="return BerMoms(this.form)" name="txtBelInkl" size="8">Kr <em>(inkl.
      moms)</em></small></small></small></font></td>
      <td valign="middle" align="center" width="144" height="19" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><select size="1"
      name="cmbKBelInkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<% =sK %>      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="19" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Verifikationstext:</font></small></small></small></td>
      <td valign="middle" align="center" width="241" height="19" colspan="2" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><input type="text"
      name="txtText" size="24"></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="352" height="26" bgcolor="#FFFFFF" colspan="3"><hr>
      </td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="26" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana">Varav moms:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBelMoms" size="8">Kr</font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbKBelMoms">
<% =sM %>      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 1:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel1Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel1Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<% =sK %>      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 2:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel2Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel2Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<% =sK %>      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 3:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel3Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel3Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<% =sK %>      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="245" height="20" bgcolor="#FFFFFF" colspan="2"><div
      align="right"></div></td>
      <td valign="middle" align="left" width="138" height="20" bgcolor="#FFFFFF"><small><font
      face="Verdana"><input type="submit" value="Spara" name="cmdReg"></font></small></td>
    </tr>
  </table>
</form>

<form method="post"  action="<% =Del %>" onsubmit="return Radera(' <% =MaxVer %> ')"
id="Del" name="Del">
  <table border="0" width="389" height="58">
    <tr>
      <td valign="middle" align="center" height="1" bgcolor="#FFFFFF" colspan="2" width="172"><div
      align="left"><p><small><strong><font face="Verdana"><small>Registrerade verifikat</small></font></strong></small></td>
      <td valign="middle" align="center" height="1" bgcolor="#FFFFFF" colspan="2" width="209"><font
      face="Verdana"><small><small><strong><div align="right"><p></strong></small><input
      type="submit" value="Radera" name="cmdDel"></small></font></td>
    </tr>
    <tr>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="50"><strong><small><small><small><font
      face="Verdana">Nr</font></small></small></small></strong></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="118"><font
      face="Verdana"><strong><small><small><small>Datum</small></small></small></strong></font></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="86"><strong><small><small><small><font
      face="Verdana">Text</font></small></small></small></strong></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="119"><font
      face="Verdana"><div align="right"><p valign="middle"><strong><small><small><small>Belopp</small></small></small></strong></font></td>
    </tr>
<% = sTab %>
  </table>
</form>
</body>
</html>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2791734
Then you have more than one error.

I am sorry. I do not do ASP.

CJ does...

Michel

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2791737
Next time, please post the html found when you do a view source instead of the asp page...

Michel
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:TTom
ID: 2791822
Wading through a LOT of code, it appears to me that the formLoad() function simply assigns the value of the cookie to a text box.  The info being passed in to the function in the onload event is simply the name of the form.

What's wrong with doing:

formLoad() {
  document.AddForm.txtDatum.value = getCookie("Datum")
}

If you insist on passing this information in the function, it should probably be:

onload = "formLoad('document.AddForm')"

Maybe I am missing something?

Tom
0
 
LVL 1

Author Comment

by:jannea
ID: 2791846
Tom, yes the event onload dosen't fire.
And if i getting the event to fire I loke to put more code in the function formLoad().

Another thing is:

If using:
<script LANGUAGE="VBScript">
Ill gettig Requestobject errors
</script>

If using:
<%
No problems..
%>

Why?
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2791862
I'll be looking through your code ina minute, but one thing first

To assign a value in a text box from a cookie, why not use:

<%= Request.Cookies("cookiename")%>
????

It's way easier than to use javascript this way.
0
 
LVL 1

Author Comment

by:jannea
ID: 2792986
CJ,

The thing is that I like several things happen in the formload event: loading values from cookies, set default optionbutton position and so on using java functions. and if there is an event, I am wondering why it dosen fire.

/Janne
0
 
LVL 9

Expert Comment

by:TTom
ID: 2793263
<script language=VBScript runat=server>

if you want to try this whole thing out with VBScript (on the CLIENT side), you will need

sub window_onload
....
end sub

That is the way to get an onload event to fire with VBS.

Does your entire form load properly and the event simply not fire?

As Michel suggested, can you post the relevant HTML code?

Tom
0
 
LVL 1

Author Comment

by:jannea
ID: 2795591
Tom,

I don't like to run VBScript on cient side.
I just want to run Java on client:

Here is the HTML-code:


<html>

<title>Kassabok - Exempelföretaget, 2000-01-01 - 2000-12-31</title>

<body>


<table border="0" width="640" >
      <tr>
      <td valign="top" colspan="2" align="center">
            <h2 align="center"><a href='inloggad.asp?ID=exft&ToDo=Rpt'><small><small><small>Rapporter  </small></small></small></a> &nbsp;<a href='inloggad.asp?ID=exft&amp;ToDo=KontoQ'><small><small><small>Kontofråga  </small></small></small></a> &nbsp;<a href='inloggad.asp?ID=exft&ToDo=Kassabok'><small><small><small>Kassabok  </small></small></small></a> &nbsp;<br>
            <font color="#400000"><small>Exempelföretaget</small></font></h2>
      </td>
      </tr>
  <tr>
    <td valign="top"><a href="LogOut.asp"><font color="#0000FF"><small>Logga ut Demo <br>
    <br>
<A href='Inloggad.asp?ID=exft'>Exempelf&#246;retaget</A><br>    </small></font></td>
    <td>
   

<head>

</head>

<body  onload="FrmLoad(document.AddForm)" topmargin="0" leftmargin="0" bgcolor="#FFFFFF" >

<form method="post" action="http://www.summagruppen.se/inloggad.asp?ID=exft&ToDo=Kassabok&AddVer=3" name="AddForm" onsubmit="return VerOk(this)">
<input type="hidden" name="hidStart" value="2000-01-01">
<input type="hidden" name="hidStopp" value="2000-12-31">
<input type="hidden" name="hidLocked" value="False">
  <table border="0" width="391" height="160">
    <tr>
      <td valign="middle" align="left" width="419" height="26" bgcolor="#FFFFFF" colspan="3"><div
      align="center"><center><p><font face="Verdana"><small><small><small>Mejla min kontakt <a href='mailto:lars.lejdborg@summagruppen.se?subject=Kassaboken - Exempelf&#246;retaget'>Lars Lejdborg</a> &nbsp; <a href=javascript:getWin('http://www.summagruppen.se/kassalage.asp?KID=exft',540,480)>Lägesrapport</a> &nbsp; <a href=javascript:getWin('http://www.summagruppen.se/kalkylatorn.htm',325,185)>Kalkylatorn</a> &nbsp; <a href=javascript:getSIE('http://www.summagruppen.se/kassasie.asp?KID=exft')>SIE-Fil</a></small></small></small></font></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Verifikationsdatum:</font></small></small></small></td>
      <td valign="middle" align="right" width="93" height="26" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><input type="text"
      name="txtDatum" size="9" value="2000-05-08"></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><strong>Verifikationsnr:</strong> <strong><font color="#0000FF">3</font></strong></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="19" bgcolor="#FFFFFF"><font
      face="Verdana">
      <input type="radio" onclick="return getIngUtgMoms(this.form,'Ut')" value="Ut"
      name="InUt"><small><small><small>Uttag</small></small></small>
      <input type="radio" onclick="return getIngUtgMoms(this.form,'In')" value="In" name="InUt" checked><small><small><small>Insättning</small></small></small></font></td>
      <td valign="middle" align="center" width="93" height="19" bgcolor="#FFFFFF"><div
      align="left"><p><font face="Verdana"><small><small><small><input type="text" value="0.00"
      onKeyUp="return isAmt(this)" onblur="return BerMoms(this.form)" name="txtBelInkl" size="8">Kr <em>(inkl.
      moms)</em></small></small></small></font></td>
      <td valign="middle" align="center" width="144" height="19" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><select size="1"
      name="cmbKBelInkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<option>1220, Inventarier och verktyg (Över 2000:-)</option>
<option>1240, Bilar och andra transportmedel</option>
<option>1510, Kundfordringar</option>
<option>1910, Kassa</option>
<option>1920, Postgiro</option>
<option>1930, Checkräkningskonto</option>
<option>1940, Bank</option>
<option>2010, Min plånbok</option>
<option>2012, Avräkn skatter och avgifter</option>
<option>2013, Övriga egna uttag</option>
<option>2440, Leverantörsskulder</option>
<option>2610, Moms på mina sålda varor & tjänster 25%</option>
<option>2620, Moms på mina sålda varor & tjänster 12%</option>
<option>2630, Moms på mina sålda varor & tjänster 6%</option>
<option>2640, Moms på mina inköp</option>
<option>2650, Momsskuld</option>
<option>2710, Personalens skatt</option>
<option>2731, Sociala avgifter</option>
<option>3010, Mina sålda varor & tjänster</option>
<option>4010, Inköp råvaror/förnödenheter,Sv</option>
<option>5010, Lokalhyra</option>
<option>5020, Elavgifter för belysning</option>
<option>5050, Lokaltillbehör</option>
<option>5210, Hyra maskiner/tekn anl</option>
<option>5410, Förbrukningsinventarier (max 2000:-)</option>
<option>5460, Förbrukningsmaterial</option>
<option>5800, Resekostnader</option>
<option>6071, Representation, avdragsgill</option>
<option>6072, Representation, ej avdragsgill</option>
<option>6110, Kontorsmateriel</option>
<option>6211, Telefon</option>
<option>6212, Mobiltelefon</option>
<option>6250, Avgifter till posten</option>
<option>6310, Företagsförsäkringar</option>
<option>6530, Redovisningstjänster</option>
<option>6570, Bankkostnader</option>
<option>6970, Tidningar/tidskrifter/facklitt</option>
<option>6982, Föreningsavg, ej avdragsgilla</option>
<option>6991, Övr externa utg,avdragsgilla</option>
<option>6992, Övr externa utg, ej avdragsg</option>
<option>7410, Pensionsförsäkringsavgifter</option>
<option>8400, Räntekostnader</option>
<option>8422, Dröjsmålsräntor lev.skulder</option>
      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="182" height="19" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Verifikationstext:</font></small></small></small></td>
      <td valign="middle" align="center" width="241" height="19" colspan="2" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana"><input type="text"
      name="txtText" size="24"></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="352" height="26" bgcolor="#FFFFFF" colspan="3"><hr>
      </td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="26" bgcolor="#FFFFFF"><div
      align="left"><p><small><small><small><font face="Verdana">Varav moms:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBelMoms" size="8">Kr</font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbKBelMoms">
<option>2610, Moms på mina sålda varor & tjänster 25%</option>
<option>2620, Moms på mina sålda varor & tjänster 12%</option>
<option>2630, Moms på mina sålda varor & tjänster 6%</option>
<option>2640, Moms på mina inköp</option>
      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 1:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel1Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel1Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<option>1220, Inventarier och verktyg (Över 2000:-)</option>
<option>1240, Bilar och andra transportmedel</option>
<option>1510, Kundfordringar</option>
<option>1910, Kassa</option>
<option>1920, Postgiro</option>
<option>1930, Checkräkningskonto</option>
<option>1940, Bank</option>
<option>2010, Min plånbok</option>
<option>2012, Avräkn skatter och avgifter</option>
<option>2013, Övriga egna uttag</option>
<option>2440, Leverantörsskulder</option>
<option>2610, Moms på mina sålda varor & tjänster 25%</option>
<option>2620, Moms på mina sålda varor & tjänster 12%</option>
<option>2630, Moms på mina sålda varor & tjänster 6%</option>
<option>2640, Moms på mina inköp</option>
<option>2650, Momsskuld</option>
<option>2710, Personalens skatt</option>
<option>2731, Sociala avgifter</option>
<option>3010, Mina sålda varor & tjänster</option>
<option>4010, Inköp råvaror/förnödenheter,Sv</option>
<option>5010, Lokalhyra</option>
<option>5020, Elavgifter för belysning</option>
<option>5050, Lokaltillbehör</option>
<option>5210, Hyra maskiner/tekn anl</option>
<option>5410, Förbrukningsinventarier (max 2000:-)</option>
<option>5460, Förbrukningsmaterial</option>
<option>5800, Resekostnader</option>
<option>6071, Representation, avdragsgill</option>
<option>6072, Representation, ej avdragsgill</option>
<option>6110, Kontorsmateriel</option>
<option>6211, Telefon</option>
<option>6212, Mobiltelefon</option>
<option>6250, Avgifter till posten</option>
<option>6310, Företagsförsäkringar</option>
<option>6530, Redovisningstjänster</option>
<option>6570, Bankkostnader</option>
<option>6970, Tidningar/tidskrifter/facklitt</option>
<option>6982, Föreningsavg, ej avdragsgilla</option>
<option>6991, Övr externa utg,avdragsgilla</option>
<option>6992, Övr externa utg, ej avdragsg</option>
<option>7410, Pensionsförsäkringsavgifter</option>
<option>8400, Räntekostnader</option>
<option>8422, Dröjsmålsräntor lev.skulder</option>
      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 2:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel2Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="26" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel2Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<option>1220, Inventarier och verktyg (Över 2000:-)</option>
<option>1240, Bilar och andra transportmedel</option>
<option>1510, Kundfordringar</option>
<option>1910, Kassa</option>
<option>1920, Postgiro</option>
<option>1930, Checkräkningskonto</option>
<option>1940, Bank</option>
<option>2010, Min plånbok</option>
<option>2012, Avräkn skatter och avgifter</option>
<option>2013, Övriga egna uttag</option>
<option>2440, Leverantörsskulder</option>
<option>2610, Moms på mina sålda varor & tjänster 25%</option>
<option>2620, Moms på mina sålda varor & tjänster 12%</option>
<option>2630, Moms på mina sålda varor & tjänster 6%</option>
<option>2640, Moms på mina inköp</option>
<option>2650, Momsskuld</option>
<option>2710, Personalens skatt</option>
<option>2731, Sociala avgifter</option>
<option>3010, Mina sålda varor & tjänster</option>
<option>4010, Inköp råvaror/förnödenheter,Sv</option>
<option>5010, Lokalhyra</option>
<option>5020, Elavgifter för belysning</option>
<option>5050, Lokaltillbehör</option>
<option>5210, Hyra maskiner/tekn anl</option>
<option>5410, Förbrukningsinventarier (max 2000:-)</option>
<option>5460, Förbrukningsmaterial</option>
<option>5800, Resekostnader</option>
<option>6071, Representation, avdragsgill</option>
<option>6072, Representation, ej avdragsgill</option>
<option>6110, Kontorsmateriel</option>
<option>6211, Telefon</option>
<option>6212, Mobiltelefon</option>
<option>6250, Avgifter till posten</option>
<option>6310, Företagsförsäkringar</option>
<option>6530, Redovisningstjänster</option>
<option>6570, Bankkostnader</option>
<option>6970, Tidningar/tidskrifter/facklitt</option>
<option>6982, Föreningsavg, ej avdragsgilla</option>
<option>6991, Övr externa utg,avdragsgilla</option>
<option>6992, Övr externa utg, ej avdragsg</option>
<option>7410, Pensionsförsäkringsavgifter</option>
<option>8400, Räntekostnader</option>
<option>8422, Dröjsmålsräntor lev.skulder</option>
      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="135" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana">Belopp 3:</font></small></small></small></td>
      <td valign="middle" align="left" width="91" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><input type="text" value="0.00" onBlur="return isAmt(this,true)"
      onKeyUp="return isAmt(this)" name="txtBel3Exkl" size="8">Kr <em>(exkl. moms)</em></font></small></small></small></td>
      <td valign="middle" align="left" width="144" height="20" bgcolor="#FFFFFF"><small><small><small><font
      face="Verdana"><select size="1" name="cmbBel3Exkl">
        <option selected value="&lt;Välj konto&gt;">&lt;Välj konto&gt;</option>
<option>1220, Inventarier och verktyg (Över 2000:-)</option>
<option>1240, Bilar och andra transportmedel</option>
<option>1510, Kundfordringar</option>
<option>1910, Kassa</option>
<option>1920, Postgiro</option>
<option>1930, Checkräkningskonto</option>
<option>1940, Bank</option>
<option>2010, Min plånbok</option>
<option>2012, Avräkn skatter och avgifter</option>
<option>2013, Övriga egna uttag</option>
<option>2440, Leverantörsskulder</option>
<option>2610, Moms på mina sålda varor & tjänster 25%</option>
<option>2620, Moms på mina sålda varor & tjänster 12%</option>
<option>2630, Moms på mina sålda varor & tjänster 6%</option>
<option>2640, Moms på mina inköp</option>
<option>2650, Momsskuld</option>
<option>2710, Personalens skatt</option>
<option>2731, Sociala avgifter</option>
<option>3010, Mina sålda varor & tjänster</option>
<option>4010, Inköp råvaror/förnödenheter,Sv</option>
<option>5010, Lokalhyra</option>
<option>5020, Elavgifter för belysning</option>
<option>5050, Lokaltillbehör</option>
<option>5210, Hyra maskiner/tekn anl</option>
<option>5410, Förbrukningsinventarier (max 2000:-)</option>
<option>5460, Förbrukningsmaterial</option>
<option>5800, Resekostnader</option>
<option>6071, Representation, avdragsgill</option>
<option>6072, Representation, ej avdragsgill</option>
<option>6110, Kontorsmateriel</option>
<option>6211, Telefon</option>
<option>6212, Mobiltelefon</option>
<option>6250, Avgifter till posten</option>
<option>6310, Företagsförsäkringar</option>
<option>6530, Redovisningstjänster</option>
<option>6570, Bankkostnader</option>
<option>6970, Tidningar/tidskrifter/facklitt</option>
<option>6982, Föreningsavg, ej avdragsgilla</option>
<option>6991, Övr externa utg,avdragsgilla</option>
<option>6992, Övr externa utg, ej avdragsg</option>
<option>7410, Pensionsförsäkringsavgifter</option>
<option>8400, Räntekostnader</option>
<option>8422, Dröjsmålsräntor lev.skulder</option>
      </select></font></small></small></small></td>
    </tr>
    <tr align="center">
      <td valign="middle" align="left" width="245" height="20" bgcolor="#FFFFFF" colspan="2"><div
      align="right"></div></td>
      <td valign="middle" align="left" width="138" height="20" bgcolor="#FFFFFF"><small><font
      face="Verdana"><input type="submit" value="Spara" name="cmdReg"></font></small></td>
    </tr>
  </table>
</form>

<form method="post"  action="http://www.summagruppen.se/inloggad.asp?ID=exft&ToDo=Kassabok&DelVer=2" onsubmit="return Radera(' 2 ')"
id="Del" name="Del">
  <table border="0" width="389" height="58">
    <tr>
      <td valign="middle" align="center" height="1" bgcolor="#FFFFFF" colspan="2" width="172"><div
      align="left"><p><small><strong><font face="Verdana"><small>Registrerade verifikat</small></font></strong></small></td>
      <td valign="middle" align="center" height="1" bgcolor="#FFFFFF" colspan="2" width="209"><font
      face="Verdana"><small><small><strong><div align="right"><p></strong></small><input
      type="submit" value="Radera" name="cmdDel"></small></font></td>
    </tr>
    <tr>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="50"><strong><small><small><small><font
      face="Verdana">Nr</font></small></small></small></strong></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="118"><font
      face="Verdana"><strong><small><small><small>Datum</small></small></small></strong></font></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="86"><strong><small><small><small><font
      face="Verdana">Text</font></small></small></small></strong></td>
      <td valign="middle" align="left" height="15" bgcolor="#FFFFFF" width="119"><font
      face="Verdana"><div align="right"><p valign="middle"><strong><small><small><small>Belopp</small></small></small></strong></font></td>
    </tr>
    <tr>    <tr>      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'><a href=javascript:getWin('http://www.summagruppen.se/KassaVer.asp?ID=2&KID=exft',400,270)>2</a></font></small></small></small></td>
      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>2000-05-04</font></small></small></small></td>
      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>Expressen faktura 45</font></small></small></small></td>
      <td valign='middle' align='right' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>10 000,00</font></small></small></small></td>
</tr>
      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'><a href=javascript:getWin('http://www.summagruppen.se/KassaVer.asp?ID=1&KID=exft',400,270)>1</a></font></small></small></small></td>
      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>2000-05-04</font></small></small></small></td>
      <td valign='middle' align='left' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>Aftonbladet</font></small></small></small></td>
      <td valign='middle' align='right' height='15' bgcolor='#FFFFFF'><small><small><small>
        <font face='Verdana'>10 000,00</font></small></small></small></td>
</tr>

  </table>
</form>
</body>
</html>

<SCRIPT LANGUAGE=JavaScript>
// constants for DateArray indexes:
var CC = 0;
var YY = 1;
var MM = 2;
var DD = 3;
//---------------------------------------------------------------------------------------------------
function DatumOk(InDatum,MinDatum,MaxDatum) {
if ((InDatum==null) || (InDatum=="")) return false;
if (InDatum.length==10) {
    // parse string:
    var DateArray = new Array(4);
    DateArray[CC] = InDatum.substring(0, 2)/1;
    DateArray[YY] = InDatum.substring(2, 4)/1;
    DateArray[MM] = InDatum.substring(5, 7)/1;
    DateArray[DD] = InDatum.substring(8, 10)/1;
    //Kolla bindestreck i datum
    var s = 's'
    s = InDatum.substring(4, 5);
    if (s != '-') return false;
    s = InDatum.substring(7, 8);
    if (s != '-') return false;
    //Kolla att resten är siffror.
      s = InDatum.substring(0, 4)+InDatum.substring(5, 7)+InDatum.substring(8, 10);
    if (IsAllDigits(s)!= true) return false;
    //Kolla att datum ej ligger innan MINdatum.
      if ((MinDatum!=null) && (MinDatum!="")){
            var s2 = MinDatum.substring(0, 4)+MinDatum.substring(5, 7)+MinDatum.substring(8, 10);
            if (s<s2) return false;
            }
    //Kolla att datum ej ligger efter MAXdatum.
      if ((MaxDatum!=null) && (MaxDatum!="")){
            var s3 = MaxDatum.substring(0, 4)+MaxDatum.substring(5, 7)+MaxDatum.substring(8, 10);
            if (s>s3) return false;
            }
    return VerifyDate(DateArray);
    }
}

//---------------------------------------------------------------------------------------------------
function IsLeapYear(ccyy) {
  // NB: ccyy is the year including century digits.
  // 1st test - if ccyy divisible by 400, then it IS a leap year:
  if (ccyy%400==0)
    return true;

  // 2nd test - if ccyy divisible by 100 (but not 400), then it is NOT a leap year:
  else if (ccyy%100==0)
    return false;

  // 3rd test - if ccyy divisible by 4 (but not 100), then it IS a leap year:
  else if (ccyy%4==0)
    return true;

  // if all test fail, ccyy is not a leap year
  else
    return false;
}


//---------------------------------------------------------------------------------------------------
function NumDaysIn(month1, year1, century1) {
  if (month1==2) {
    // February - must check for leap year
    if (IsLeapYear(100*century1/1+year1/1))
      return 29;
    else
      return 28;
  }
  else if ((month1==4) || (month1==6) || (month1==9) || (month1==11))
    return 30;
  else
    return 31;
}


//---------------------------------------------------------------------------------------------------
function VerifyDate(DateArray) {
  // Checks that the date specified by DateArray is valid:
  // NB: Only works for years AD, not BC.

  var century = DateArray[CC];
  var year = DateArray[YY];
  var month = DateArray[MM];
  var day = DateArray[DD];

  // 1st check - century must be non-negative:
  if (century<0)
    return false;

  // 1st check - year must be from 00..99:
  if ((year<0) || (year>99))
    return false;

  // 2nd check - month1 must be between 1 and 12:
  if ((month<1) || (month>12))
    return false;

  // 3rd check - day1 must be between 1 and the number of days in the specified month:
  if ((day<1) || (day>NumDaysIn(month, year, century)))
    return false;

    // if we get this far, the date is OK:
  return true;
}


//---------------------------------------------------------------------------------------------------
function IsAllDigits(aString) {
  var ch;
  for (var i=0; i<aString.length; i++) {
    ch = aString.charAt(i);
    if (!((ch>='0') && (ch<='9')))
      return false;
  }
  // if we get to here must be ok
  return true;
}

</script>
<script LANGUAGE="JavaScript">
//*****  Janne, Copyright© SummaGruppen AB 2000  *****
//**Skriva & Hämta cookie

function setCookie(name1,value1)
{
      var today = new Date();
      var expires = new Date();
      expires.setTime(today.getTime() + 60*60*24*365*10000);
      document.cookie = name1 + "=" + value1 + "; expires=" + expires.toGMTString();
}
function getCookie(Name)
{          
      var search = Name + "="          
      if (document.cookie.length > 0)
            { // om de finns cookies                    
                  offset = document.cookie.indexOf(search)                    
                  if (offset != -1)
                        { // Om cookien finns                            
                              offset += search.length  // Index på början av värdet
                              end = document.cookie.indexOf(";", offset) // Index på slutet av värdet
                              if (end == -1)
                              end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))                    
                        }
            }
}
//**Skall köras när formuläret laddas.
function FrmLoad(form)
{
      alert("FrmLoad");
      form.txtDatum.value=getCookie("Datum");
      //forms.elements[0].focus();
}

//Kollar momssats
function GetMoms(ctl)
{
      var str1 = "" + ctl.valueselected
      alert("str1=" + str1);
      var i = str1.indexOf("%");
      alert("i=" + i);
      //if (i=-1) return(0.2);//Ej hittat %
      var str2 = str1.substr(i-2, 2);
      i=parseint(str2)
      return(i);
}


//**Beräknar momsen och belopp exkl. moms.
function BerMoms(form)
{
      isAmt(form.txtBelInkl,true);
      form.txtBelMoms.value=form.txtBelInkl.value*0.2;
      isAmt(form.txtBelMoms,true);
      form.txtBel1Exkl.value=form.txtBelInkl.value - form.txtBelMoms.value;
      isAmt(form.txtBel1Exkl,true);
      //alert(GetMoms(form.cmbKBelMoms))
}
//**Kolla att endast tal
function isAmt(field,done) {
   tstr=""+field.value;
   OK = true;
   nofPoints = 0;
   for (var i=0;i<tstr.length;i++) {
      if ('0123456789.'.indexOf(tstr.charAt(i)) ==-1) {
         if (done!=true) alert('Endast siffror och punkt (.) som decimalavgränsare, negativa tal är ej tillåtna.');
         OK=false;
         break;
      }
      else if (tstr.charAt(i)=='.') nofPoints++;
      if (nofPoints > 1) {
         if (done!=true) alert('Endast EN punkt (.) som decimalavgränsare.');
         OK=false;
         break;          
      }
   }
   if (!OK) {
      if (i>0) field.value=tstr.substring(0,i);
      else field.value ='';
   }
   else if (done) { //Formatera textfält med 2 decimaler
      dotPos = tstr.indexOf('.')
      decimals = tstr.substring(dotPos+1)    
      if (nofPoints > 0) {
         if (decimals.length < 2) {
            field.value += '00'.substring(0,2-decimals.length);
             
         }
         else field.value = tstr.substring(0,dotPos) + "" + tstr.substring(dotPos,dotPos+3)    
      }
      else field.value += '.00';
   }
      //Returnera summan i textfält
      return field.value;
}



//**Öppna nytt fönster
function getWin(url,W,H)
{
      var s='location=no,scrollbars=yes,toolbar=no,width=' + W + ',height=' + H;
      window.open(url,'_blank',s);
}


//**Skapa SIE.
function getSIE(url)
{
      alert("Denna funktion är ej klar ännu.");
}


//**Kolla om kontonummer är markerat
function KontoOK(ctl)
{

      if (ctl.selectedIndex ==0)
      //if (ctl.value.indexOf("<") + "" != "-1")
            {
                  alert("Du måste fylla i ett konto först.")
                  ctl.focus()
                  return false;
            }
      else return true;
}

//**Sätta Ing. eller Utg. momskonto berene på Inkomst/Utgift
function getIngUtgMoms(form,v)
{
      var i = 0
      if (v=="Ut") i=3;
      form.cmbKBelMoms.selectedIndex = i;
}


//**Radera senaste verifikat.
function Radera(VerNr)
{
     if (VerNr == 0)
        {
           alert("Det finns inget registrerat verifikat att radera.");
           return false;
          }
      var b = window.confirm ("Är det OK att radera det senast registrerade verifikatet (Nummer " + VerNr + ") ?");
      return  b;
}


//Kolla att verifikat är rätt ifyllt.
function VerOk(form)
{
      if (form.hidLocked.value!='False'){
            alert("Räkenskapsåret (" + form.hidStart.value + " - " + form.hidStopp.value + ") är låst, så du kan ej längre spara verifikat på detta år.");
                  form.txtDatum.focus()
                  return false;
}
      var b = false
//Hämta belopp från textfälten
      var BelInkl = isAmt(form.txtBelInkl,true);
      var belM = isAmt(form.txtBelMoms,true);
      var bel1 = isAmt(form.txtBel1Exkl,true);
      var bel2 = isAmt(form.txtBel2Exkl,true);
      var bel3 = isAmt(form.txtBel3Exkl,true);
      
//Kolla om giltigt verifikatonsdatum
      if (DatumOk(form.txtDatum.value,form.hidStart.value,form.hidStopp.value) != true)
            {
                  alert("Ogiltigt verifikationsdatum. Datumet skall ha formatet 'åååå-mm-dd' och måste ligga inom räkenskapsåret (" + form.hidStart.value + " - " + form.hidStopp.value + ").");
                  form.txtDatum.focus()
                  return false;
            }
//Kolla att belopp inkl. moms är ifyllt
    if (BelInkl == "" || BelInkl == null || BelInkl < 0.01)
            {
                  alert("Du måste fylla i beloppet inkl. moms.")
                  form.txtBelInkl.focus()
                  return false;
            }
//Kolla att KONTO för belopp inkl. moms är ifyllt
      b=KontoOK(form.cmbKBelInkl)
      if (b != true)return false;
//Kolla om verifikattext är ifylld.
    if (form.txtText.value == "" || form.txtText.value == null )
            {
                  alert("Du måste fylla i en verifikatiostext.")
                  form.txtText.focus()
                  return false;
            }
//Kolla att konto ifyllt om momsbelopp ifyllt.
      b=true
      //if (belM>0) b=KontoOK(form.cmbKBelMoms)      
      if (b != true )return false;
//Kolla att KONTO för belopp1 är ifyllt om belopp1 >0.
      b=true
      if (bel1>0) b=KontoOK(form.cmbBel1Exkl)      
      if (b != true )return false;
//Kolla att KONTO för belopp2 är ifyllt om belopp2 >0.
      b=true
      if (bel2>0) b=KontoOK(form.cmbBel2Exkl)      
      if (b != true )return false;
//Kolla att KONTO för belopp3 är ifyllt om belopp3 >0.
      b=true
      if (bel3>0) b=KontoOK(form.cmbBel3Exkl)      
      if (b != true )return false;
//Kolla om verifikatet balanserar
      var diff = BelInkl - belM - bel1 - bel2 - bel3;
      if (diff<0) diff=diff*-1;//Ev teckenvända
      if (diff != 0)
            {
                  alert("Verifikatet balanserar inte, det diffar på " + diff + " Kr")
                  form.txtBel1Exkl.focus()
                  return false;
            }
//Har nu klarat alla tester.
      setCookie("Datum",form.txtDatum.value);
      return true;
}

</script>
    </td>
  </tr>
</table>

<p>&nbsp; </a>
</FONT>
</body>
</html>
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2795848
The problem is definitely there because you don't have a cookie on the computer which contains something. The cookie will only be set IF you have filled something in, and submitted the form. In the FrmLoad you should check if the cookie you get is in the right format and especially IF there is a cookie. If there is not, set it to a value. And then read it...

that way it'll work.it's what i did, I put a setCookie("Datum", "hi") at the start of the FrmLoad and it worked just fine....you should just check whether there is a cookie, if not, set it.

Good luck,
CJ
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2795904
You have multiple body tags and the scripts should really be in the head of the file. It might not matter, but one never knows with stricter browsers

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2795909
That would by the way explain it since the first body tag does not have an onLoad

Michel
0
 
LVL 1

Author Comment

by:jannea
ID: 2796226
Michel & CJ,

I have notice and change that thing with 2 bodytags, and getting the same result.

CJ, never mind the cookie, the problem is that the event won't fire in my IE4 browser. if I run it it Netscape® Communicator 4.61 the event is fired.

Any ideas?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 2796279
It fires fine in IE5

Michel
0
 
LVL 1

Author Comment

by:jannea
ID: 2840615
I did upgrade to IE5, and now it works.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now