Results 1 to 6 of 6

Thread: A simple VBScript error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312

    A simple VBScript error

    Code:
    <html><head><title>Testing, will it work??? Probalbly not!</title></head>
    <BODY>
    
    <H1>Welcome to the Visual Basic Quiz!</h1>
    Please make a choice by Clciking the appropriate answer<p><br>
    What does Stephen Hawking do for a living?<p>
    
    <form name="frm">
    <input type="radio" NAME="radq1" CHECKED> Engineer<BR>
    <input type="radio" NAME="radq1"> Physisist<BR>
    <input type="radio" NAME="radq1"> Accountant<BR>
    <input type="radio" NAME="radq1"> Unemployed<BR><br><p>
    <input type="button" NAME="B1" Value = "Click to check your answer!"><p>
    
    <INPUT TYPE="text" NAME="txtMsg" Size="50"><p></form>
    
    <SCRIPT LANGUAGE="VBS">
    Dim NumGos
    Sub b1_Onclick
    NumGos = Numgos + 1
    if frm.radq1.item(1).checked then
    frm.txmsg.value = "Well done! You are right after" & Cstr(NumGos)
    if numgos = 1 then
    frm.txmsg.value = frm.txmsg.value & "Try"
    else
    frm.txmsg.value = frm.txmsg.value & "Tries"
    end if
    
    if numgos = 2 then
    msgbox("Right First Time - Ya lucky git!")
    end if
    else
    frm txmsg.value = "Wrong, ya DUMB ass!"
    end if
    End Sub
    </SCRIPT>
    </BODY></HTML>
    thats it, and it dont work, just get an error in the status bar that says error on page!

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Well, I do all of my client side stuff in JavaScript, so I haven't got a care, but..

    Code:
    frm txmsg.value
    That line is missing a dot.
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    if your talking about the

    frm txmsg.value = "Wrong, ya DUMB ass!"

    then it didnt work putting a . inbetweeb the from txmsg

    but it does need ot be there so thanx, still an error though

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You mis-spelled the name of your textbox nearly everywhere.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    Lively Member
    Join Date
    Jan 2001
    Posts
    118
    and

    msgbox("Right First Time - Ya lucky git!")

    should be msgbox "Right First Time - Ya lucky git!"

    No "(" & ")"

    If you want "(" ..

    X = msgbox("Are you sure?" ,vbyesno + vbquestion,"Question")

    if x = vbyes then
    Msgbox "yes"
    else
    msgobx "no"
    end if

  6. #6
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    For that matter, you shouldn't be using Msgbox on a web page at all.. there is a whole other thread on this topic, but suffice to say you should be using:

    window.alert "blahblahblah"
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

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