Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Just fiddlin' around - What's wrong with this???

Posted on 2002-04-02
5
Medium Priority
?
166 Views
Last Modified: 2010-04-09
Hi there.  I'm not doing anything really important, but I can't figure out why this code doesn't work.  Can someone point me in the right direction.

<code>
<HTML>
<HEAD>
<TITLE> My First Attempt at VB Script!</TITLE>

<SCRIPT LANGUAGE="VBSCRIPT" TYPE="text/vbs">

<!-- Instruct non-IE browsers to skip over scripts

    Sub MYBUTTON_OnClick
     MsgBox "Over the hills and through the woods, to grandmothers house we go!"
    End Sub

    Sub MYBUTTON2_OnClick
     DIM X
     X = INPUTBOX("Enter Your Name:")
         if X = "" then
          Exit Sub
         end if
     MsgBox "Your Name is: " & X
    End Sub

    Sub CALC_OnClick
     msgbox ((document.myform.FSTNUM.VALUE) + (document.myform.SECNUM.VALUE))
    end sub
-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR = 'beige'>

<FORM NAME = "myForm">
    <INPUT TYPE = "BUTTON" NAME = "MYBUTTON" VALUE = "WOO - HOO">
    <INPUT TYPE = "BUTTON" NAME = "MYBUTTON2" VALUE = "NAME SCRIPT">
    <INPUT TYPE = "Text" NAME = "FSTNUM" VALUE = 0 SIZE = 4>
    <INPUT TYPE = "Text" NAME = "SECNUM" VALUE = 0 SIZE = 4>
    <INPUT TYPE = "BUTTON" NAME = "CALC" VALUE = "CALCULATE">
</FORM>

</BODY>
</HTML>
</code>

in the Calc_OnClick, the message box returns the values of the text boxes concatenated.  If I try multiplying, it works fine.

Thanks for any help.

DDS
0
Comment
Question by:dds110
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 6914090
  Sub CALC_OnClick
    msgbox (eval(document.myform.FSTNUM.VALUE) + eval(document.myform.SECNUM.VALUE))
   end sub
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6914091
without the eval() , the input values are treated as text, so you are concatinating two strings together.  
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 60 total points
ID: 6914096
actually, you may want to use CInt instead of eval:


   msgbox (CInt(document.myform.FSTNUM.VALUE) + CInt(document.myform.SECNUM.VALUE))
0
 
LVL 8

Author Comment

by:dds110
ID: 6921615
Thanks a bunch.
0
 
LVL 8

Author Comment

by:dds110
ID: 6921617
Thanks a bunch.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question