0
<input name="btnCetak" type="submit" class="buttonPaging" style="width:200px;" value="Kemaskini Tarikh Serahan" onclick="document.pressed=this.value" />
<input name="export" type="submit" class="buttonPaging" value="Surat Akuan" onclick="document.pressed=this.value" />

The above is my 2 different buttons. The below code is my script function, chkCheckBox.

function chkCheckBox() 
{
    if(document.pressed=="Surat Akuan")
    {   
        var a=new Array();
        a=document.getElementsByName("chkCetak[]");
        var p=0;

        for(i=0;i<a.length;i++)
        {
            if(a[i].checked)
                p=1;
        }

        if (p==0)
        {
            alert('Sila pilih Nama Pemohon.');
            return false;
        } 
        else 
        {
            var total=""
            for(var x=0; x< document.myForm.elements['chkCetak[]'].length;x++)
            {
                if(document.myForm.elements['chkCetak[]'][x].checked)
                    total +=document.myForm.elements['chkCetak[]'][x].value + "\n"
            }       

            if(total=="") 
            {

            } 
            else 
            { 
                document.myForm.submit();
                return true; 
            }
        }
    }
}

chkCheckBox works. My question is: How do I want to redirect to the other page when the "Surat Akuan" button is clicked?

rootmeanclaire
  • 808
  • 3
  • 13
  • 37
user3487681
  • 149
  • 1
  • 1
  • 9

1 Answers1

0

Just redirect?

location.href = "your link here";

you can find more info by google it, one of the link you can look on Window.location.href and Window.open () methods in JavaScript

Community
  • 1
  • 1
Se0ng11
  • 2,303
  • 2
  • 26
  • 45
  • I have tried to put that statement in last else statement. but it not redirect to the page i want. i also have tried using window location.. – user3487681 May 06 '14 at 02:13
  • what mean last statement? after total =="" if else statement? have you try to debug whether it meet the condition? – Se0ng11 May 06 '14 at 02:17