Results 1 to 23 of 23

Thread: VBScript (Easy one)

  1. #1

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330

    VBScript (Easy one)

    He everyone,

    I want to make my form pass the data into a string when the button is clicked... But it ain't working...

    Code:
    <HTML>
      <HEAD>
        <TITLE>Test formulier</TITLE>
        <SCRIPT language="VBScript ">
           function cmdToHosting_OnClick()
             Dim strOrganisatie
          
             strOrganisatie = Document.persgegevens.organisatie.Value
             MsgBox ("Data =" & StrOrganistatie)
           End Sub
        </SCRIPT>
      </HEAD>
      <BODY>
        <FORM method=GET name="pergegevens" border="1">
         <TR>
           <TD>
             Naam organisatie
           </TD>
           <TD>
             <INPUT name="organisatie" size="30">
           </TD>
         </TR><TR>
           <TD>
             Naam contactpersoon
           </TD>
           <TD>
             <INPUT name="contactpersoon" size="30">
           </TD>
         </TR><TR>
           <TD>
             <INPUT type="button" name="cmdToHosting" value="Hosting toevoegen">
           </TD>
          </TR>
        </FORM>
      </BODY>
    </HMTL>
    Plz look for errors, cause I'm pretty new to VBScript it probably is a newbie error

    Grtz,

    Bloged

    P.S. Can you pass data between two forms located on other pages wich are loaded after eachother

  2. #2
    kayoca
    Guest
    You can use this.
    Code:
    <INPUT type="button" name="cmdToHosting" value="Hosting toevoegen" onclick="cmdToHosting_OnClick()
    ">

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Your inputs have no type attribute. You should add type=Text to your input tags.

    Get out of the habit of using Msgbox on a web page. Use window.alert instead. If you use Msgbox in server side code, you will do one of two things: Cause an error, or stop the application with a modal dialog box on the server.
    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..

  4. #4

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    The first thing: I already tried that... so that wasn't a succes!

    The second thing: Tnxs I'm used to program in Visual Basic..

    Grtz,

    Bloged

  5. #5
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    <SCRIPT language="VBScript ">
    Sub cmdToHosting_OnClick()
    Dim strOrganisatie

    strOrganisatie = Document.persgegevens.organisatie.Value
    MsgBox ("Data =" & StrOrganistatie)
    End Sub
    </SCRIPT>

    Regards,

    El-Nino

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Cause an error, or stop the application with a modal dialog box on the server.
    If would have to be an error, because if you made a dialog box, it would be near impossible to click it.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  7. #7
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    If you have debugging turned on in IIS, it will pop up the dialog box and the app will stop until it is clicked. Otherwise, it will simply not do anything. Point is, don't use MsgBox on web pages.. there are better alternatives.
    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..

  8. #8

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Ok I've changed the Function in a Sub and replaced MsgBox with Window.Alert

    Now it comes with a Runtime error

    Line 30
    cmdToHosting_OnClick is not defined

    I hope I translated the error OK cause my browser is in Dutch

    Grtz,

    Bloged

    P.S. Is VBScript Case-Sensitive

  9. #9
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    If you have debugging turned on in IIS, it will pop up the dialog box and the app will stop until it is clicked.
    Where would the dialog box pop-up? I wouldn't think it would have a screen to paint itself on.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  10. #10

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    He JoshT

    Where would the dialog box pop-up? I wouldn't think it would have a screen to paint itself on.
    What do you mean with this???

    Grtz,

    Bloged

  11. #11
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Make sure your control has the same name as in your script .

    As for case sensivity, No, VBScript isn't case sensitive !

    Good luck
    Regards,

    El-Nino

  12. #12
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Oops, I forgot you posted the whole code and the names matches Sorry, i dunno what's the problem then with the names...!
    Regards,

    El-Nino

  13. #13

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Ok I've done that already!

    So what can it be...

    Plz post some code how you would do this... Get the value of a INPUT field and load it into a string....

    Grtz,

    Bloged

  14. #14
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Bloged: Repost your modified version of the code.

    Josh: If you have IIS debugging enabled, a msgbox will popup on the server if you use it in server side script. That is the only way it will do it. When debugging is not enabled, the ASP processor ignores Msgbox.
    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..

  15. #15
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    you spelled </html> wrong, you did </hmtl>

  16. #16
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    monte96: This is what's throwing me off: Since the web server generally runs with the anonymous user account, wouldn't the Msgbox have to go to the anonymous user's screen, which doesn't exist? Or does it get displayed to whoever is locally logged on's screen ("interact with desktop" rights), and if the server would be sitting there at the log-on screen, it would pop up there?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  17. #17
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Unhappy

    I suggest you try doing it in jScript.
    cos it will be browser neutral

    -abhijit

  18. #18
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Hi there,
    I would like to present a solution.
    here is your code re-written.

    One thing, in your code you have opened a function but closed it with an End Sub. I wonder why?



    <HTML>
    <HEAD>
    <META name=VI60_defaultClientScript content=VBScript>
    <TITLE>Test formulier</TITLE>
    <SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
    <!--

    Sub cmdToHosting_onclick
    Dim strOrganisatie
    Dim strcontactpersoon
    strOrganisatie = pergegevens.organisatie.value
    strcontactpersoon = pergegevens.organisatie.value
    MsgBox ("Data =" & strOrganisatie & " " & strcontactpersoon)
    End Sub

    -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM name="pergegevens" method="get">
    <TABLE border="1">
    <TR>
    <TD>
    Naam organisatie
    </TD>
    <TD>
    <INPUT name="organisatie" size="30">
    </TD>
    </TR><TR>
    <TD>
    Naam contactpersoon
    </TD>
    <TD>
    <INPUT name="contactpersoon" size="30">
    </TD>
    </TR><TR>
    <TD>
    <INPUT
    type="button"
    name="cmdToHosting"
    value="Hosting toevoegen">
    </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>

  19. #19
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    JoshT: I think the assumption here is that you wouldn't turn on IIS debugging on a production server that was inaccessable. You would be logged on to do the debugging. But, yes, it would get displayed to the current logged in interactive account.
    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..

  20. #20

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    The Code above repeats the First string...

    When I want to use another JavaScript too I probaply have to rewrite my code don't I or is there a way you can combine them...

    Grtz,

    Bloged

  21. #21
    Addicted Member
    Join Date
    May 2001
    Posts
    153

    Re: VBScript (Easy one)

    Hi there,

    Just observe ur code

    function cmdToHosting_OnClick() ----Function starts here.
    Dim strOrganisatie

    strOrganisatie = Document.persgegevens.organisatie.Value
    MsgBox ("Data =" & StrOrganistatie)
    End Sub --- Ended with a procedure ? it should start as a
    proc. right?
    Last edited by Venkrishna; Jun 15th, 2001 at 05:10 AM.
    there r no alternatives 4 hardwork.

  22. #22

    Thread Starter
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    End Sub --- Ended with a procedure ? it should be End function right?
    I'm a intermediate VBProgrammer and I just started vbScript so: I don't understand you're question, or I'm doing something totally wrong (probably both)...

    Grtz,

    Bloged

  23. #23
    Addicted Member
    Join Date
    May 2001
    Posts
    153
    Hi blogged,

    may be i have confused u

    replace ur code with the procedure as below.

    Sub cmdToHosting_onclick()

    ' ur code

    End sub.

    Hope I am clear now.
    there r no alternatives 4 hardwork.

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