Results 1 to 16 of 16

Thread: What's wrong w/ this code ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    Exclamation What's wrong w/ this code ?

    <SCRIPT LANGUAGE="VBScript">
    <!--

    Sub cmdNotifier_OnClick()
    Dim i

    With document.frmNotification
    .Atteindre.value = ""
    For i = 1 to <%= rsPrets.RecordCount %>
    If .chkNotifier(i).checked = True Then
    .Atteindre.value = .Atteindre.value & .chkNotifier(i).value & ";"
    End if
    Next
    End With
    msgbox .Atteindre.value
    End Sub

    ' -->
    </SCRIPT>

    </HEAD>
    <BODY bgcolor="#0D0D6D" text="black" >
    <Form name=frmNotification method=post>
    <Table height=239 cellPadding=10 width=396 align=center bgColor=#d4d0c8 border=8 style="WIDTH: 396px; HEIGHT: 239px" id=TABLE1>

    <% rsPrets.MoveFirst
    While not rsPrets.EOF %>
    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=<%= rsPrets.AbsolutePosition%> type=checkbox checked></Td>

    </Tr>
    <% rsPrets.MoveNext
    Wend %>
    </Table>
    </Td></Tr>
    <Tr><Td align="MIDDLE">
    <INPUT Type="button" name="cmdNotifier" id=cmdNotifier value="Notifier">
    <INPUT TYPE="button" VALUE="Fermer" id=cmdFermer name=cmdFermer><br>
    </Td></Tr>
    </Table>
    <INPUT TYPE="hidden" SIZE="4" NAME="MoveAction" value="Move">

    </BODY>
    </HTML>



    I got error in VBScript, when clicking on cmdNotifier :
    chkNotifier : Object not defined
    Regards,

    El-Nino

  2. #2
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    Do you have a copy of the produced html? the original ASP doesnt help diagnose browser problems...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    <HTML>
    <HEAD>


    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub Main()
    End Sub

    Sub cmdFermer_OnClick()
    document.location.href="frmDefault.asp"
    End Sub

    Sub cmdNotifier_OnClick()
    Dim i

    With document.frmNotification
    .Atteindre.value = ""
    For i = 1 to 3
    If .chkNotifier(i).checked = True Then
    .Atteindre.value = .Atteindre.value & .chkNotifier(i).value & ";"
    End if
    Next
    End With
    msgbox .Atteindre.value
    End Sub

    ' -->
    </SCRIPT>


    </HEAD>

    <BODY bgcolor="#0D0D6D" text="black" onload="Call Main()">
    <Form name=frmNotification method=post>
    <Table height=239 cellPadding=10 width=396 align=center bgColor=#d4d0c8 border=8 style="WIDTH: 396px; HEIGHT: 239px" id=TABLE1>
    <Tr><Td>
    <B>Notification</B><HR><BR>
    <Table border=1 width=500>
    <Tr><Td Width=20></Td>
    <Td Width=160><Font Face="Courier New" size=2>User</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>Prog</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>Return Date</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>*</Font></Td>
    </Tr>

    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=1 type=checkbox checked></Td>
    <Td Width=160><Font Face="Courier New" size=2>Test name</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>Test proggie</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>2001-06-07</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>0</Font></Td>
    </Tr>
    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=2 type=checkbox checked></Td>
    <Td Width=160><Font Face="Courier New" size=2>Test name2</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>Test proggie2</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>2001-06-07</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>0</Font></Td>
    </Tr>

    </Table>
    </Td></Tr>
    <Tr><Td align="MIDDLE">
    <INPUT Type="button" name="cmdNotifier" id=cmdNotifier value="Notifier">
    <INPUT TYPE="button" VALUE="Fermer" id=cmdFermer name=cmdFermer><br>
    </Td></Tr>
    </Table>
    <INPUT TYPE="hidden" SIZE="4" NAME="MoveAction" Value="Move">
    <INPUT TYPE="hidden" SIZE="4" NAME="Atteindre">
    </Form>

    </BODY>
    </HTML>
    Last edited by eL_NiNo; Jun 12th, 2001 at 01:18 PM.
    Regards,

    El-Nino

  4. #4
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    You only have one checkbox assigned to the name "chknotifier", but your trying to check three of them...

    Plus make sure all your values in HTML have speech marks round them, or netscape will cough up a lung.

  5. #5
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Oh, sorry, forgot to mention.

    In the DOM, a single element does not create an array of length 1. If you have two, then you have an array of length 2.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Ok assume the statement repeats 3 times (hence the 3 in the for) I cut it out coz It was not relevant to this post since it's exactly the same except : Testuser2 Testporggie2 and so on...
    Regards,

    El-Nino

  7. #7
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    Dude, you have a syntax error, which means one single character could be wrong, so I need ALL of the code, from the server, not as you think it should be.. Or Its impossible to solve.. The code as you put it should work, but Id take out the "with" command, as vbscript support of that has always been flaky between browser sub-versions..

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    Ok I'll repost it soon !

    If it can help

    I'll repost the whole code but I can't see what's wrong :P
    Regards,

    El-Nino

  9. #9
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    If you post it all, Ill find out whats wrong with it, I guarantee

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    Here you go once again :p

    <HTML>
    <HEAD>


    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub Main()
    End Sub

    Sub cmdFermer_OnClick()
    document.location.href="frmDefault.asp"
    End Sub

    Sub cmdNotifier_OnClick()
    Dim i

    With document.frmNotification
    .Atteindre.value = ""
    For i = 1 to 3
    If .chkNotifier(i).checked = True Then
    .Atteindre.value = .Atteindre.value & ";" & .chkNotifier(i).value
    End if
    Next

    ' On élimine le ";" au début
    If .Atteindre.value <> "" Then .Atteindre.value = Right(.Atteindre.value, Len(.Atteindre.value) - 1)
    End With
    msgbox .Atteindre.value
    End Sub

    ' -->
    </SCRIPT>


    </HEAD>

    <BODY bgcolor="#0D0D6D" text="black" onload="Call Main()">
    <Form name=frmNotification method=post>
    <Table height=239 cellPadding=10 width=396 align=center bgColor=#d4d0c8 border=8 style="WIDTH: 396px; HEIGHT: 239px" id=TABLE1>
    <Tr><Td>
    <B>Notification</B><HR><BR>
    <Table border=1 width=500>
    <Tr><Td Width=20></Td>
    <Td Width=160><Font Face="Courier New" size=2>User</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>App</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>Date</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>*</Font></Td>
    </Tr>

    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=1 type=checkbox checked></Td>
    <Td Width=160><Font Face="Courier New" size=2>Name 1</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>App 1</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>2001-06-07</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>0</Font></Td>
    </Tr>

    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=2 type=checkbox checked></Td>
    <Td Width=160><Font Face="Courier New" size=2>Name 2</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>App 2</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>2001-06-08</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>0</Font></Td>
    </Tr>

    <Tr><Td Width=20><Input name=chkNotifier id=chkNotifier Value=3 type=checkbox checked></Td>
    <Td Width=160><Font Face="Courier New" size=2>Name 3</Font></Td>
    <Td Width=200><Font Face="Courier New" size=2>App 3</Font></Td>
    <Td Width=100><Font Face="Courier New" size=2>2001-06-08</Font></Td>
    <Td Width=40 Align="Middle"><Font Face="Courier New" size=2>0</Font></Td>
    </Tr>

    </Table>
    * Notifié
    </Td></Tr>
    <Tr><Td align="MIDDLE">
    <INPUT Type="button" name="cmdNotifier" id=cmdNotifier value="Notifier">
    <INPUT TYPE="button" VALUE="Fermer" id=cmdFermer name=cmdFermer><br>
    </Td></Tr>
    </Table>
    <INPUT TYPE="hidden" SIZE="4" NAME="MoveAction" Value="Move">
    <INPUT TYPE="hidden" SIZE="4" NAME="Atteindre">
    </Form>

    </BODY>
    </HTML>
    Regards,

    El-Nino

  11. #11
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    I just spotted the problem This isnt VB, its HTML, and on click events dont do anything. You need to put a little bit of code in the submit tag. Possibly this..

    onsubmit="cmdNotifier_OnClick"


    Also it should be a type="submit" not type="button", "button" doesnt work in all browsers.


    Hope this helps

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Actually this works; clicking on the button calls the cmdNotifier_OnClick()

    The problem is in the script itself or in my location of checkbox, I don't know but it's strarting to annoy me
    Regards,

    El-Nino

  13. #13
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    I tried it on ie6/5/4 and netscape 6/4 and none of them do anything... Not a sausage. Where are you testing it? And what should it do? I cant even get your error.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    IE5.5

    And this is working pretty well with all the other pages I made...
    Regards,

    El-Nino

  15. #15
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    I must admit, Im having some problems understanding the purpose of the page, but I have spotted something. Checkbox arrays in vbscript start with 0 dont they? That may explain why it cant find the checkbox our after..

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    No more worries

    Well forget this thread guys; I figured out what was my problem; I rewrote it completly and it works now; seems like the checkboxes didn't like the value statement given by my ASP, so I used another way to do that, thanks !

    Thanks for all help !
    Regards,

    El-Nino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width