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
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Getting a True Value for CheckBox - Javascript

    I am trying to figure out a "True" value as well as a "or" command. Any ideas? I need this script to run through the list and look to see if a value is true. Right now it looks through all 6 lines and if all are null, if they are it returns false. Heres the little bit:

    if ((regExp1.exec(str_arrVals) == null)
    (regExp2.exec(str_arrVals) == null) ||
    (regExp3.exec(str_arrVals) == null) ||
    (regExp4.exec(str_arrVals) == null) ||
    (regExp5.exec(str_arrVals) == null) ||
    (regExp6.exec(str_arrVals) == null)) {
    alert("Please check a AA\nThank You");
    return false;


    Here's an idea of what I need: (Note that "CHECKED" does not actually work.)


    if ((regExp1.exec(str_arrVals) == CHECKED)) {
    return true;
    }

    else if ((regExp2.exec(str_arrVals) == CHECKED)) {
    return true;
    }

    else{
    alert("Please make a selection\nThank You");
    return false;
    }



    Heres the whole actual code i'm working with:



    <script type="text/javascript" language="javascript">
    <!-- Begin
    js_globalArr = new Array();

    function js_buildArrStructure(f_cBoxArg){

    if(f_cBoxArg.checked == true){

    fn_cBoxArr = new Array();
    fn_cBoxArr.push(f_cBoxArg.name);
    fn_cBoxArr.push(f_cBoxArg.value);
    js_globalArr.push(fn_cBoxArr);

    } else{

    fn_remVal = new Array();

    fn_remVal.push(f_cBoxArg.name);
    fn_remVal.push(f_cBoxArg.value);

    if(js_globalArr.length == 1){

    js_globalArr = js_globalArr.unshift();
    js_globalArr = new Array();

    } else{

    for(var s_index = 0; s_index < js_globalArr.length; s_index++){
    tmp_arr = new Array();
    tmp_arr = js_globalArr[s_index];

    if(tmp_arr.toString() == fn_remVal.toString()){

    js_globalArr.splice(s_index, 1);

    } else{

    continue;
    }
    }
    }
    }
    }


    function cBoxValidate(){

    var str_arrVals = "";
    var regExp1 = new RegExp("UPSzGround", "g");
    var regExp2 = new RegExp("UPSz2ndzDayzAir", "g");
    var regExp3 = new RegExp("UPSzNextzDayzAir", "g");
    var regExp4 = new RegExp("UPSz2ndzDayzAKxHI", "g");
    var regExp5 = new RegExp("USPSzExpresszCanada", "g");
    var regExp6 = new RegExp("USPSzGlobalzPriority", "g");

    str_arrVals = js_globalArr.toString();

    if ((regExp1.exec(str_arrVals) == null)
    (regExp2.exec(str_arrVals) == null) ||
    (regExp3.exec(str_arrVals) == null) ||
    (regExp4.exec(str_arrVals) == null) ||
    (regExp5.exec(str_arrVals) == null) ||
    (regExp6.exec(str_arrVals) == null)) {
    alert("Please check a AA\nThank You");
    return false;

    } else if(regExp2.exec(str_arrVals) == null) {
    alert("Please check a DD\nThank You");
    return false;
    } else{
    return true;
    }
    }
    // END-->
    </script>



    Any comments or suggestions is greatly apreciated. Thanks for your time.

    ~Isaac Lloyd~
    Last edited by isaaclloyd; 03-22-2005 at 08:18 PM.
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #2
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I fixed my own answer in time. Here is what I needed:



    <script type="text/javascript" language="javascript">
    <!-- Begin

    function valBox(){
    if(document.getElementById("C1").checked==true){
    return true;
    }
    else if(document.getElementById("C2").checked==true){
    return true;
    }
    else{
    alert('YAY!');
    return false;
    }
    }

    // END-->
    </script>




    ~Isaac Lloyd~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com


  •  

    Posting Permissions

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