Jump to content

Window pop up not work properly


fansa

Recommended Posts

Hye all,

 

I have some problem about message box.The message only run button OK but button CANCEL not function properly.Hope have anybody can help me to solve this problem.Attached here is the some of the coading

 

function save()

{

var purchase = document.adjust.purchase

 

  if(disp_confirm2() == false){

    return false;

  }

 

 

  return true

}

 

 

function disp_confirm2()

{

var r=confirm("Are You Sure To save?");

if (r==true)

  {

  return true;

  }

else

  {

  return false;

  }

}

 

 

 

  <input type="submit" class="button" name="Save" value="Save" onclick="save()">

 

Link to comment
https://forums.phpfreaks.com/topic/139823-window-pop-up-not-work-properly/
Share on other sites

I think you for got some else statement

function save()
{
   var purchase = document.adjust.purchase

   if(disp_confirm2() == false){
     return false;
   } else {
    return true;
    }
}


function disp_confirm2()
{
var r=confirm("Are You Sure To save?");
if (r==true)
  {
  return true;
  }
else
  {
  return false;
  }
}
   


  <input type="submit" class="button" name="Save" value="Save" onclick="save()">

change both buttons to

 

<input type="button" value="OK" onclick="disp_confirm(this.value.toLowerCase())"

 

and

 

<input type="button" value="CANCEL" onclick="disp_confirm(this.value.toLowerCase())"/>

 

then have a function

 

function disp_confirm(v) {

  if (v == 'ok') {

    // do whatever for OK

  } else if (v == 'cancel') {

    // do whatever for CANCEL

  }

  else {

    alert("Error: Invalid button");

  }

}

 

btw this is a javascript question and will most likely get moved..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.