Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window confirm

Status
Not open for further replies.

yukeshean

Programmer
Aug 24, 2001
9
MY
hi,
In javascript, if i need a confirm window (dialog box) with more than 2 default buttons (ok, and cancel)...which means maybe add in a "yes to all" button. How should i do this?

Please give me some advice.
Thanks


Regards,
yukeshean
 
i guess it is vbscript related question.. at least i haven't heard of thus stuff in javascript.. Victor
 
I don't think you can specify buttons with the confirm window in javascript.
 
Why don't you just create your own confirm box with a new popup window. Then put all the buttons you want to your hearts delight !!

You can even do this without having to go to the server for any HTML.

Need some help ??

ToddWW :)
 
if you have an ie only target group, check out making vb script boxes:

theEclipse
eclipse_web@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Well, here's an example of a customized window with buttons. I tried to make it so you can edit the parameters as easy as possible, including number of buttons, button text, and return value for each button. You'll be able to completely customize the alert window by editing the code in RED. Everything else can remain as is. This is IE and NS compatible. Go ahead and copy the page onto your server and run it as is so you can see how it works.


<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--

// THIS SETS THE ALERT WINDOW
// AS A GLOBAL VARIABLE
var myAlert

// THIS ADDS THE BUTTONS TO A
// TWO DIMENSIONAL ARRAY
// DO NOT EDIT
function button_Def(text,value) {
this.text = text
this.value = value
}

// THIS DEFINES THE BUTTONS YOU WANT
// IN THE POPUP WINDOW.
var buttonGroup = new Array(3) // # OF BUTTONS
buttonGroup[0] = new button_Def('O.K.',1)
buttonGroup[1] = new button_Def('Cancel',2)
buttonGroup[2] = new button_Def('Change',3)

// THIS DEFINES THE WINDOW PARAMETERS
// IN THE ALERT BOX
var alert_text = &quot;Would you like to submit or would you like to change the entries ?&quot;
var alert_title = &quot;Confirmation&quot;
var winheight = '100'
var winwidth = '250'


// THIS CREATES THE DYNAMIC ALERT BOX
// DOES NOT REQUIRE ANY EDITING
function checkForm(form_ref) {
myAlert = window.open('','alert','width='+winwidth+',height='+winheight+',top=100,left=100')
var wC = '<html><head><title>'+alert_title+'</title></head>'
wC += '<body bgcolor=&quot;#C0C0C0&quot; onBlur=&quot;self.focus();&quot;>'
wC += '<table border=&quot;0&quot; width=&quot;100%&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>'
wC += '<tr><td width=&quot;100%&quot; align=&quot;center&quot;><font face=&quot;Arial&quot; size=&quot;2&quot;><strong>'
wC += alert_text
wC += '</font></strong></td></tr>'
wC += '<tr><td width=&quot;100%&quot; align=&quot;center&quot; height=&quot;50&quot;>'
for (m = 0; m < buttonGroup.length; m++) {
wC += '<input type=&quot;button&quot; '
wC += 'value=&quot;'+buttonGroup[m].text+'&quot; '
wC += 'onClick=&quot;self.opener.procButton('+buttonGroup[m].value+');&quot;>  '
}
wC += '</td></tr>'
wC += '</body></html>'
myAlert.document.open()
myAlert.document.write(wC)
myAlert.document.close()
}

// THIS IS THE FUNCTION THAT PROCESSES
// THE BUTTON CLICKS. b_val IS SET TO
// WHATEVER YOU DEFINE AS THE VALUE
// OF THE BUTTON WHEN YOU SET THOSE
// UP ABOVE.
function procButton(b_val) {
myAlert.close()
if (b_val == 1) {
document.forms[0].submit()
}
if (b_val == 2) {
// DO NOTHING THIS IS THE
// CANCEL BUTTON
}
if (b_val == 3) {
document.forms[0].firstname.value = &quot;Enter New First Name&quot;
document.forms[0].lastname.value = &quot;Enter New Last Name&quot;
}
}

//-->
</script>
</head>
<body>
<form>
First Name: <input type=&quot;text&quot; name=&quot;firstname&quot;><br>
Last Name: <input type=&quot;text&quot; name=&quot;lastname&quot;><br>
<input type=&quot;button&quot; value=&quot;Submit&quot; onClick=&quot;checkForm();&quot;>
</form>
</body>
</html>


Crazy, but it works. X-)

ToddWW
 
Dear all especially ToddWWW,

Thanks :)

Cheers,
yukeshean
p/s: I'll try out and let you know, ToddWW. Very kind of you, really...
 
Sorry, me blur blur lar....
just now the latest msg is from me yukeshean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top