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
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()">

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.