Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error

Status
Not open for further replies.

rhinton6

MIS
Jul 28, 2004
5
US
I continue to get a syntax Error where my VBScript portion of this html document is. It seems to me that it is telling me that <% %> is not correct. Also It is telling me that an object is expected on the line where <b>Staff Person Verified<b> is written. Here is my code:


Code:
<html>
  <head>
     <Title>Electronic Employee Timesheet -- Test Health Systems</Title>


     <SCRIPT LANGUAGE="JavaScript">
       //This function will collect the username & password of a staff person and authenicate them against Active Directory.
       <%
         Dim userNam, auth, strGroups

         set oSysInfo = CreateObject("ADSystemInfo")
         userNam = oSysInfo.username
         Set CurrentUser = GetObject("LDAP://" & userNam)
         strGroups = LCase(Join(CurrentUser.MemberOf))

         Const group = "cn=SR-Network_Team,OU=SR,DC=test,DC=net"

         IF InStr(1,strGroups, group,1) > 0  THEN
            auth = 1
         END IF

         IF InStr(1,strGroups, group,1) < 0  THEN
            auth = 0
         END IF
       %>
       function fnAut(){
         var passWd,userNam, auth
         passWd=prompt("User please enter your Test password:","");
         <%=auth%>=auth;
         If (auth == 1){
           document.form.StaffVerbx.checked.value=true;}
           else {alert("Your account could not be verified!");
          }
         )
     </SCRIPT>
  </head>
  <body background="E:\My Documents\Downloads\Images\chsbackground.gif"></br>
     <h1><big><center>Test Health System TimeSheet</center></big></h1></br></br>
     <form action="mailto:rhinton@test.org" method="post" name="form">
       <P>
        <b>Staff Full Name</b> <Input type="text" name="staffNam"></br>
        <b>Staff Username</b> <Input type="text" name="userNam"></br>
        <b>Staff Social Security Number</b> <Input type="text" name="socialSec"></br></br>
        <table border="1">
           <tr><th colspan="2">Week of: <Input type="text" name="payweek1"><th>Time In<th>Time Out<th>Other  (On Call, Sick,</br>Vacation, Personal, Travel,</br>Lunch)<th>Total Hours
           <tr><th colspan="2">Monday<td><Input type="text" name="monIn1"><td><Input type="text" name="monOut1"><td><Input type="text" name="monOth1"><td><Input type="text" name="monTot1">
           <tr><th colspan="2">Tuesday<td><Input type="text" name="tueIn1"><td><Input type="text" name="tueOut1"><td><Input type="text" name="tueOth1"><td><Input type="text" name="tueTot1">
           <tr><th colspan="2">Wednesday<td><Input type="text" name="wedIn1"><td><Input type="text" name="wedOut1"><td><Input type="text" name="wedOth1"><td><Input type="text" name="wedTot1">
           <tr><th colspan="2">Thursday<td><Input type="text" name="thuIn1"><td><Input type="text" name="thuOut1"><td><Input type="text" name="thuOth1"><td><Input type="text" name="thuTot1">
           <tr><th colspan="2">Friday<td><Input type="text" name="friIn1"><td><Input type="text" name="friOut1"><td><Input type="text" name="friOth1"><td><Input type="text" name="friTot1">
           <tr><th colspan="2">Saturday<td><Input type="text" name="satIn1"><td><Input type="text" name="satOut1"><td><Input type="text" name="satOth1"><td><Input type="text" name="satTot1">
           <tr><th colspan="2">Sunday<td><Input type="text" name="sunIn1"><td><Input type="text" name="sunOut1"><td><Input type="text" name="sunOth1"><td><Input type="text" name="sunTot1">
           <tr><th colspan="5" align="right"><Input type="button" name="calBtn1" value="Calculate Total Hours" onClick=> Total Hours For The Week<td><Input type="text" name="totHrs1">
        </table></br></br>
        <table border="1">
           <tr><th colspan="2">Week of: <Input type="text" name="payweek2"><th>Time In<th>Time Out<th>Other (On Call, Sick,</br>Vacation, Personal, Travel,</br>Lunch)<th>Total Hours
           <tr><th colspan="2">Monday<td><Input type="text" name="monIn2"><td><Input type="text" name="monOut2"><td><Input type="text" name="monOth2"><td><Input type="text" name="monTot2">
           <tr><th colspan="2">Tuesday<td><Input type="text" name="tueIn2"><td><Input type="text" name="tueOut2"><td><Input type="text" name="tueOth2"><td><Input type="text" name="tueTot2">
           <tr><th colspan="2">Wednesday<td><Input type="text" name="wedIn2"><td><Input type="text" name="wedOut2"><td><Input type="text" name="wedOth2"><td><Input type="text" name="wedTot2">
           <tr><th colspan="2">Thursday<td><Input type="text" name="thuIn2"><td><Input type="text" name="thuOut2"><td><Input type="text" name="thuOth2"><td><Input type="text" name="thuTot2">
           <tr><th colspan="2">Friday<td><Input type="text" name="friIn2"><td><Input type="text" name="friOut2"><td><Input type="text" name="friOth2"><td><Input type="text" name="friTot2">
           <tr><th colspan="2">Saturday<td><Input type="text" name="satIn2"><td><Input type="text" name="satOut2"><td><Input type="text" name="satOth2"><td><Input type="text" name="satTot2">
           <tr><th colspan="2">Sunday<td><Input type="text" name="sunIn2"><td><Input type="text" name="sunOut2"><td><Input type="text" name="sunOth2"><td><Input type="text" name="sunTot2">
           <tr><th colspan="5" align="right"><Input type="button" name="calBtn2" value="Calculate Total Hours"> Total Hours For The Week<td><Input type="text" name="totHrs2">
        </table></br>
        </br>
        <b>Staff Person Verified</b><Input type="checkbox" name="staffVerbx"><Input type="button" name="staffVal" value="Validate Staff Person" onclick="JfnAut()"></br>
        <b>Supervisor Full Name</b> <Input type="text" name="superNam"></br>
        <b>Supervisor Verified</b> <Input type="checkbox" name="superVerbx"> <Input type="button" name="superVal" value="Validate Supervisor" align="right" onclick="JavaScript:fnAut;"></br></br>
        <Input type="Submit" name="subBtn" value="Submit">
        <Input type="Reset" name="resetBtn" value="Reset">
       </P>
     </form>
  </body>
</html>
 
You appear to be setting a server-side variable, "auth" to either 0 or 1, and then in the client-side, you are using:

Code:
<%=auth%>=auth;

so this would evaluate to either:

Code:
0=auth;

or

Code:
1=auth;

... neither of which are valid JS, as you cannot re-define a number to be something else!

Try going over your code, rethinking your logic, and making sure you have everything right.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
If I take the <% %> tags out I don't get the syntax error. It still doesn't work, but I don't get the error. The logic I am trying to accomplish is the browser opens the page and performs the VBScript. Then the JavaScript gets the variable from auth from the VBScript and assign it to the JavaScript variable auth when the function auth is perform. Which is performed onclick with one of my buttons.
 
You have
Code:
onclick="JavaScript:fnAut;"
which isn't a function call in javascript and
Code:
onclick="JfnAut()"
which is a function call to a non-existent function.

The logic I am trying to accomplish is the browser opens the page and performs the VBScript.

This is a totally mistaken understanding of how server-side scripting (ASP in this case) works. The browser doesn't do anything with your VBScript, your web server does. The browser only sees the final HTML output. If you look at that, like cLFlaVA said, you might be able to see some of the errors, especially the one BillyRayPreachersSon pointed out.

Lee
 
I am completely lost then. What happens first? If I do view source it looks the same.
 
It appears you're running this page locally
Code:
<body background="E:\My Documents\Downloads\Images\chsbackground.gif">
rather than through a web server. If you want to process ASP code, you need to use a web server that handles that. WinXP Pro has IIS built in, and that works with ASP fine.

Lee
 
Do I need to place it on the server? Because my server does support ASP.
 
Sorry, I wasn't understanding. I will try that and see what happens.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top