小编Jas*_*aft的帖子

Javascript - 将两个输入字段相乘并显示

我的想法是,我应该有两个字段,我输入数字,然后我需要显示总和以及产品.
我想我会测试产品,但我不断收到"非数字"错误.任何帮助都会很棒!

<!DOCTYPE html>
<html>
  <body>

    <form>
        First Number<br>
        <input id="num1" type="text" name="num1">
    <br>
        Second Number:<br>
        <input id="num2" type="text" name="num2">
        <br><br>
      <input type="button" value="Do Maths" onclick="doMath();" />
    </form>

  <script>

      function doMath() {
          var numOne = document.getElementById('num1').value;
          var numTwo = document.getElementById('num2').value;
          var theProduct = parseInt(my_input1) * parseInt(my_input2);  document.write(theProduct);
          document.write(theProduct);


}

  </script>


  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript forms math function getelementbyid

1
推荐指数
1
解决办法
2614
查看次数

不包含带有3个参数的构造函数

我无法让main读取我的构造函数.它一直说我的类不包含一个带有3个参数的构造函数.这是公开的.我不知道我做错了什么,我在成功之前做过这个,这是我用来学习测试的练习题.

public class Actor
{
    //attributes 
    private string name;
    private int awardsNum;
    private bool SAGMember;

    //property 

    private string name
    {
        get { return name; }
        set { name = value; }

    }


    //constructor 

    public Actor(string Name, int AwardsNum, bool SAGMember)
    {
        this.name = Name;
        this.awardsNum = AwardsNum ++;
        this.SAGMember = false;
    }

    public Actor()
    {
    this.name = "Bob Smith";
    this.awardsNum = 0 ;
    this.SAGMember = false;
    }

    public override string ToString ()
    {
        return string.Format ("Actor: " + name + …
Run Code Online (Sandbox Code Playgroud)

c# constructor

-2
推荐指数
1
解决办法
741
查看次数

标签 统计

c# ×1

constructor ×1

forms ×1

function ×1

getelementbyid ×1

javascript ×1

math ×1