解决方案 »

  1.   

    揭帖这么快!汗!写了个小demo<table>
      <tbody>
        <tr>
          <th>2进制</th>
      <input type="text" id="txtNum"/>
          <td><input type="button" value="10转2" onclick="convert_digits_from('txtNum',2)"/></td>
        </tr>
        <tr>
          <th>3进制</th>
          <td><input type="button"  value="10转3" onclick="convert_digits_from('txtNum',3)"/></td>
        </tr>
        <tr>
          <th>4进制</th>
          <td><input type="button"  value="10转4" onclick="convert_digits_from('txtNum',4)"/></td>
        </tr>
        <tr>
          <th>5进制</th>
          <td><input type="button"  value="10转5" onclick="convert_digits_from('txtNum',5)"/></td>
        </tr>
       </tbody>
    </table>
    <script>
     var w=function(s){alert(s)}; 
    var convert_digits_from=function(num,el)
    {
    var obj=document.getElementById(num).value;
    //alert(obj);alert(el);
    //alert(obj.toString(el));
      
    w(parseInt(obj,10).toString(el));   
    };
    </script>