dongyu5104 2011-07-15 13:15
浏览 39
已采纳

从javascript函数获取复选框的value属性

I am doing this :

function GETVALUE() 
{
 if(document.getElementById("requirenewpage").checked == true)
    {
        document.getElementById("requirenewpage").value;    
        var cval= parseInt(document.getElementById("requirenewpage").value);

    }
}

HTML-----------------------------

<input type="checkbox" id="requirenewpage" unchecked   value= "GETVALUE();" >

I need to insert into a mysql table , 0 or 1, which is taken from the VALUE attribute of the checkbox.....but am not able to do it...please help???

Its always inserting 0 into the database, albeit am setting the value as 1 in the function GETVALUE().....

  • 写回答

3条回答 默认 最新

  • dongqi1245 2011-07-15 15:01
    关注

    I'm shocked that nobody has answered this correctly yet... Change the checkbox to the following:

    <input type="checkbox" id="requirenewpage" name="requirenewpage" value= "1" />
    

    The ID of an input element is used for script access and styling only, if you want to submit the element in a form it must have a name attached to it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝