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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Location
    Miami
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    checkbox checked on default

    I need to have "Chk1" checkbox check the first time the person logs in the page, and the rest is either checkbox 1 or 2 just like I have.. This is for a search textbox , which you could search by lastname or firstname.
    . The only problem is to have checkbox 1 checked the first time,, could someone help with that. thanks


    <SCRIPT LANGUAGE="JavaScript">
    function setChecked(checkName)
    {
    var doc = document.Compaq;
    if (checkName == "chk1")
    {
    doc.Chk2.checked = 0;
    }
    else
    if (checkName == "chk2")
    {
    doc.Chk1.checked = 0;
    }

    }
    </SCRIPT>

    <FORM METHOD="POST" ACTION="test.cfm" NAME="Compaq">
    <INPUT TYPE="CHECKBOX" NAME="Chk1" VALUE="1" ONCLICK="setChecked('chk1')">Check 1

    <INPUT TYPE="CHECKBOX" NAME="Chk2" VALUE="2" ONCLICK="setChecked('chk2')">Check 2

    </FORM>

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <INPUT TYPE="CHECKBOX" NAME="Chk1" VALUE="1" ONCLICK="setChecked('chk1')" checked>Check 1

    ....Willy

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you saying that you want to force the user to choose one or the other? i think willy got it right, but im not sure.

    Also, for the checkbox, you should use:

    <input type="checkbox" checked="checked" ... />

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Loke this maybe?


    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function init(){
    document.Compaq.Chk1.checked=true
    document.Compaq.Chk2.checked=false
    }
    function setChecked(checkName){
    var doc = document.Compaq;
    if (checkName == "chk1"){
    doc.Chk2.checked = 0;
    }
    else
    if (checkName == "chk2"){
    doc.Chk1.checked = 0;
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY onload="init()">
    <FORM METHOD="POST" ACTION="test.cfm" NAME="Compaq">
    <INPUT TYPE="CHECKBOX" NAME="Chk1" VALUE="1" ONCLICK="setChecked('chk1')">Check 1
    <INPUT TYPE="CHECKBOX" NAME="Chk2" VALUE="2" ONCLICK="setChecked('chk2')">Check 2
    </FORM>
    </BODY>
    </HTML>



  • #5
    New to the CF scene
    Join Date
    Oct 2003
    Location
    Miami
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you

    Thank you to all of you. This is what I was looking for. thanks again


    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function init(){
    document.Compaq.Chk1.checked=true
    document.Compaq.Chk2.checked=false
    }
    function setChecked(checkName){
    var doc = document.Compaq;
    if (checkName == "chk1"){
    doc.Chk2.checked = 0;
    }
    else
    if (checkName == "chk2"){
    doc.Chk1.checked = 0;
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY onload="init()">
    <FORM METHOD="POST" ACTION="test.cfm" NAME="Compaq">
    <INPUT TYPE="CHECKBOX" NAME="Chk1" VALUE="1" ONCLICK="setChecked('chk1')">Check 1
    <INPUT TYPE="CHECKBOX" NAME="Chk2" VALUE="2" ONCLICK="setChecked('chk2')">Check 2
    </FORM>
    </BODY>
    </HTML>


  •  

    Posting Permissions

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