nitinafre
asked on
'Yes', 'No' and 'Cancel'
Hello Experts,
The predefined methods in javascript is alert, with ok button, confirm with 'Ok' and 'Cancel' button and prompt which I don't need. I want the method to show the dialog box with 'Yes', 'No' and 'Cancel' button. Is there any method for that. It will better if we can give the customize name to buttons. That will be additional.
Thanx in advance.
Nitin
The predefined methods in javascript is alert, with ok button, confirm with 'Ok' and 'Cancel' button and prompt which I don't need. I want the method to show the dialog box with 'Yes', 'No' and 'Cancel' button. Is there any method for that. It will better if we can give the customize name to buttons. That will be additional.
Thanx in advance.
Nitin
I don't think this is possible... The Alert and Confirm methods are predefined.
Yup.
There are only 3 predefined functions namely
window.alert(),
window.confirm(),
window.prompt in javascript.
alert have 1 button (ok)
confirm have 2 buttons (ok,cancel)
prompt have 2 buttons (ok, cancel)
Good Luck
There are only 3 predefined functions namely
window.alert(),
window.confirm(),
window.prompt in javascript.
alert have 1 button (ok)
confirm have 2 buttons (ok,cancel)
prompt have 2 buttons (ok, cancel)
Good Luck
And I can't find any predefined function in the client-side javascript1.3 reference and guide from iplanet.
If you want the latest reference and standard of javascript, you can go to
http://docs.iplanet.com/docs/manuals/javascript.html
(But the spec there do not designed for IE, so you can find sth only defined by IE)
If you want the latest reference and standard of javascript, you can go to
http://docs.iplanet.com/docs/manuals/javascript.html
(But the spec there do not designed for IE, so you can find sth only defined by IE)
typo. can't find sth only defined by IE
there is a way , but i think it works only in IE
build a html page with 3 buttons in it : OK, CANCEL and NO.. put in there everything you want
and then use window.showModalDialog(..) to display this html page.. (read MSDN for more details)
rgds
build a html page with 3 buttons in it : OK, CANCEL and NO.. put in there everything you want
and then use window.showModalDialog(..)
rgds
Or use a layer - works in any v4 browser
Michel
Michel
PS: If you were going to use IE specific code you might as well use an msgbox
Michel
Michel
The modal window option, or the VB options only work in IE, though you could just use a plain new window for netscape, personally I would go with Mplunjan's sugestion of a layer...best all round option there....
Regards
JB
Regards
JB
Some more points would be welcome ;-)
<html>
<head>
<title>Prompt using window</title>
</head>
<body>
<script>
/* prompt function
(c) copyright 2000-2001 Michel Plungjan michel@irt.org */
function showMsg(msg,title) {
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center> ';
text += '<input type="button" value="Yes" onClick="window.showResult (1)">';
text += '<input type="button" value="No" onClick="window.showResult (2)">';
text += '<input type="button" value="Cancel" onClick="window.showResult (3)">';
text += '</center></td></tr></tabl e>';
text += '</form>';
if (document.all) {
mDiv = document.all.msgDiv;
mDiv.innerHTML = text;
mDiv.style.visibility = 'visible';
}
else if (document.layers) {
mDiv = document.layers['msgDiv'];
with (mDiv.document) {
write(text);
close();
}
mDiv.visibility = 'visible';
}
else if (document.getElementById) {
mDiv = document.getElementById('m sgDiv');
mDiv.innerHTML = text;
mDiv.style.visibility = 'visible';
}
}
function showResult(result) {
alert('User answered: '+result)
if (document.all) {
mDivSt = document.all('msgDiv').sty le;
}
else if (document.layers) {
mDivSt = document.layers['msgDiv'];
}
else if (document.getElementById) {
mDivSt = document.getElementById('m sgDiv').st yle;
}
mDivSt.visibility = 'hidden';
}
</script>
<a href="#" onClick="showMsg('Hello',' title'); return false">layer alert</a>
<div style="position:absolute;t op:300;lef t:400;visi bility:hid den" id="msgDiv"></div>
</body>
</html>
<html>
<head>
<title>Prompt using window</title>
</head>
<body>
<script>
/* prompt function
(c) copyright 2000-2001 Michel Plungjan michel@irt.org */
function showMsg(msg,title) {
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center>
text += '<input type="button" value="Yes" onClick="window.showResult
text += '<input type="button" value="No" onClick="window.showResult
text += '<input type="button" value="Cancel" onClick="window.showResult
text += '</center></td></tr></tabl
text += '</form>';
if (document.all) {
mDiv = document.all.msgDiv;
mDiv.innerHTML = text;
mDiv.style.visibility = 'visible';
}
else if (document.layers) {
mDiv = document.layers['msgDiv'];
with (mDiv.document) {
write(text);
close();
}
mDiv.visibility = 'visible';
}
else if (document.getElementById) {
mDiv = document.getElementById('m
mDiv.innerHTML = text;
mDiv.style.visibility = 'visible';
}
}
function showResult(result) {
alert('User answered: '+result)
if (document.all) {
mDivSt = document.all('msgDiv').sty
}
else if (document.layers) {
mDivSt = document.layers['msgDiv'];
}
else if (document.getElementById) {
mDivSt = document.getElementById('m
}
mDivSt.visibility = 'hidden';
}
</script>
<a href="#" onClick="showMsg('Hello','
<div style="position:absolute;t
</body>
</html>
Sorry, old title
Michel
Michel
ASKER
wow, thatnks for all the 'MESSAGE'. well even ididn't find any thing on that, thats why i came here. Making of another html for that was in my mind infact, but i thouht if there is any solution. i'll try the example of Michel. lets see. in fact i didn't know much about layers, if u can tell me a bit regarding that.
Thanks for all
Nitin
Thanks for all
Nitin
It is not possible to change the buttons using Javascript. The text in the buttons depends on the Language that IE and Windows is using. For example, I am using IE and Windows in Spanish, the name of the buttons in the dialog box are "ACEPTAR" instead of "OK" and "CANCELAR" instead of "CANCEL". This is automatic. If Windows and IE were in Japanese it'll probably display something in Japanese....
Anyway, there is no way to do what you want, at least, not using the ALERT method in Javascript. You could use your own made-by-you message box......
Anyway, there is no way to do what you want, at least, not using the ALERT method in Javascript. You could use your own made-by-you message box......
Good point, the original question was, "can I change the default buttons..." (more or less), not can I create my own dialog box with custom buttons...
Mikes suggestion is a good one if you want to use DHTML, it's not really what you asked, but it will do...
Mikes suggestion is a good one if you want to use DHTML, it's not really what you asked, but it will do...
The name is Michel, please...
Michel
Michel
ASKER
Actually tried to made the message box. But I want to pass the parameter to html page for displaying message and names of the button. In showModalDialog, I was trying to call asp but don't seems to be possible so easily. So I can pass the parameter to html page then might possible. So any suggestion at that ground?
Nitin
Nitin
Sorry Michel, no offense intended.
In my script, change
function showMsg(msg,title) {
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center> ';
text += '<input type="button" value="Yes" onClick="window.showResult (1)">';
text += '<input type="button" value="No" onClick="window.showResult (2)">';
text += '<input type="button" value="Cancel" onClick="window.showResult (3)">';
text += '</center></td></tr></tabl e>';
text += '</form>';
to
function showMsg(msg,title,b1,b2,b3 ) {
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center> ';
text += '<input type="button" value="'+b1+'" onClick="window.showResult (1)">';
text += '<input type="button" value=""'+b2+'" onClick="window.showResult (2)">';
text += '<input type="button" value=""'+b3+'" onClick="window.showResult (3)">';
text += '</center></td></tr></tabl e>';
text += '</form>';
and the link to
<a href="#" onClick="showMsg('Hello',' title','Ye s','No','C ancel'); return false">layer alert</a>
or use an array of names - also good if you may have different number of buttons
Michel
function showMsg(msg,title) {
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center>
text += '<input type="button" value="Yes" onClick="window.showResult
text += '<input type="button" value="No" onClick="window.showResult
text += '<input type="button" value="Cancel" onClick="window.showResult
text += '</center></td></tr></tabl
text += '</form>';
to
function showMsg(msg,title,b1,b2,b3
text = '<form>';
text += '<table border=2><tr><td bgcolor=blue>'
text += '<font color=white><b>';
text += title;
text += '</b></td></tr><tr><td bgcolor=lightgrey>';
text += msg;
text += '</td></tr><tr><td bgcolor=lightgrey><center>
text += '<input type="button" value="'+b1+'" onClick="window.showResult
text += '<input type="button" value=""'+b2+'" onClick="window.showResult
text += '<input type="button" value=""'+b3+'" onClick="window.showResult
text += '</center></td></tr></tabl
text += '</form>';
and the link to
<a href="#" onClick="showMsg('Hello','
or use an array of names - also good if you may have different number of buttons
Michel
ASKER
If I say that the showModalDialog will be the better option but there must be the way to find the way by which rather calling an HTML page, we can call an ASP page. So that we can pass the parameters easily. What the Michel has given is not what exaclty I want. I am too findong on that line and still trying but hope you may get it soon. pls
Nitin
Nitin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well I think i should accept your answer. With the showModalDialog function I got what I want and it is working very fine. Thanx.
Nitin
Nitin
May I then ask why I only got a B? You already gave very little points - why make it worse?
Michel
Michel
ASKER
Well Sorry but what is that "B"? And it is not that I reduced points. I was not having that much of points when I posted the question. Well if now possible to improve then I am ready. Just tell me.