Combine 2 Script that will work together..

Discussion in 'JavaScript' started by b007, Sep 1, 2008.

  1. #1
    Hi,
    I got a validation script and a confirm script,
    I want that if the validation return false than no to do the confirm func.
    just return a msg in the lable text as it does.
    and if the validation return true than do the confirm func.
    and if I press on ok at the confirm than return true , cancel return false.
    My 2 Scripts are:

    function Validate()
    {
    var radiobuttonList = document.getElementsByName("MyRadioButton1");
    var isSelected = false;
    for( i=0; i<radiobuttonList.length;i++)
    {
    if (radiobuttonList.checked)
    {
    isSelected = true;
    }
    }
    if(!isSelected)
    document.getElementById("lblTEXT1").innerText = "Must select a row";

    return isSelected;
    }
    --------------
    function confirmDelete()
    {
    var answer = confirm("?are u sure")
    if (answer)
    {
    alert("msg delete");
    return true;
    }
    else
    {
    alert("msg not delete");
    return false;
    }
    }

    How to do that?
    Thanks, Gil

     
    b007, Sep 1, 2008 IP
  2. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if (radiobuttonList.checked.value=(value))
    Checked is a property of the radio button which contains the value it is to have when checked.

    <input TYPE="radio" checked="on">

    If the radio button is selected it will return a value of "on"
     
    Sleeping Troll, Sep 2, 2008 IP