try thisfunction test(){
  var a;
  var b;
  var c;
  a = Form1.start.value;
  b = parseInt(Form1.end.value);
  c = parseInt(a.substring(0,3));
  Form1.ymd.value = c*1000000 + b;
}

解决方案 »

  1.   

    他总是说(var c)这行错误:Form1未定义!是怎么回事?
      

  2.   

    html>
    <title>test</title>
    <body>
    <form name="form1">
    <table>
      <tr>
        <td>start</td>
        <td><input type="text" name="start" value=""></td>
      </tr>
      <tr>
        <td>end</td>
        <td><input type="text" name="end" value=""></td>
      </tr>
    </table>
    <input type="hidden" name="NO" value="">
    <input type="button" value="submit" onclick="doSubmit()">
    </form>
    </body>
    <script language="javascript">
      function doSubmit() {
        var a,b,c;
        a = document.form1.start.value;
        b = document.form1.end.value;
        if( a > 1000 ) {
          a = a / 10;
        }
        document.form1.NO.value = a * 1000000 + b;
        document.form1.submit();
      }</script>
    </html>我想问document.form1.NO.value = a * 1000000 + b;  这行怎么才能数值相加而不是字符串的连接?
    还有a = a / 10怎么取整? 
      

  3.   

    document.form1.NO.value = a*1 * 1000000 + b
      

  4.   

    <script language="javascript">
      function doSubmit() {
        var a,b;
        a = new Number(document.form1.stationno.value);
        b = new Number(document.form1.callno.value);
        if( a > 1000 ) {
          a = Math.round(a / 10);
        }
        document.form1.callno1.value = a * 1000000 + b;
        document.form1.submit();
      }
    </script>
      

  5.   

    <script language="javascript">
      function doSubmit() {
        var a,b;
        a = new Number(document.form1.stationno.value);
        b = new Number(document.form1.callno.value);
        if( a > 1000 ) {
          a = Math.round(a / 10);
        }
        document.form1.callno1.value = a * 1000000 + b;
        document.form1.submit();
      }
    </script>