Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change checkbox value

    Is this how you change checkbox value?
    If so, it seems that I cant pass my value for SQL processing once I unchecked the checked box.

    Javascipt:
    Code:
    function changevalue()
    {
    	box = eval("document.form1.gopublic");
    	if (box.checked == false) 
    	{
    		alert("disallow");
    		document.form1.gopublic[0].value = "disallow";
    	}
    	else
    	{
    		alert("allow");
    		document.form1.gopublic[0].value = "allow";
    	}
    }
    HTML
    Code:
    <input name="gopublic" type="checkbox" id="gopublic" value="allow" checked="checked"  onclick="changevalue()"/>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    un unchecked checkbox is not an active element, thus it's value will not be submit. Use rather a pair of radio buttons, one of them checeked by default.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •