PDA

Click to See Complete Forum and Search --> : What's wrong w/ this code ?


eL_NiNo
Jun 12th, 2001, 10:06 AM
<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

tonyenkiducx
Jun 12th, 2001, 10:51 AM
Do you have a copy of the produced html? the original ASP doesnt help diagnose browser problems...

eL_NiNo
Jun 12th, 2001, 11:06 AM
<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>

tonyenkiducx
Jun 12th, 2001, 11:11 AM
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.

CiberTHuG
Jun 12th, 2001, 11:36 AM
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.

eL_NiNo
Jun 12th, 2001, 01:17 PM
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...

tonyenkiducx
Jun 13th, 2001, 04:23 AM
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..

eL_NiNo
Jun 13th, 2001, 08:19 AM
If it can help :D

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

tonyenkiducx
Jun 13th, 2001, 09:02 AM
If you post it all, Ill find out whats wrong with it, I guarantee ;)

eL_NiNo
Jun 13th, 2001, 09:07 AM
<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>

tonyenkiducx
Jun 13th, 2001, 09:22 AM
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 :D

eL_NiNo
Jun 13th, 2001, 09:29 AM
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 :p

tonyenkiducx
Jun 13th, 2001, 09:35 AM
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.

eL_NiNo
Jun 13th, 2001, 09:40 AM
IE5.5

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

tonyenkiducx
Jun 13th, 2001, 09:43 AM
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..

eL_NiNo
Jun 13th, 2001, 10:19 AM
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 !