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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yes / NO Pop Up box..?

Status
Not open for further replies.

dhoward007

Programmer
Feb 6, 2002
45
US
I am currently using the confirm box in my page but I would like to customize the way the box looks. I would like the user to choose yes or no instead of ok or cancel.. Below is my code. Is there another way to do this?

<script language=&quot;JavaScript&quot;>
function verify() {
var answer;
answer = confirm(&quot;Are you sure you would like to shut off polling for this server?&quot;)
if (answer == 0) {
return false;
}
else {
return true;
}
}
</script>

<a href=&quot;sqlpolling.asp&quot; onClick=&quot;return verify();&quot;>ON</a>
 
The only other way to do it is to build your own dialog box in html and then call it by the showModalDialog method of the window object. Note that you'll have to return the pushed button in your dialog by returnValue property. Water is not bad as soon as it stays out human body ;-)
 
You mean that you can't do this in javascript? Vbscript will allow you to do this.. But I can't get it to work..

That is strange.. It seems like you could customize a dialog box or pop up box to change the wording on the buttons.
 
Here's how you do it in VBScript:

<script language=&quot;vbscript&quot;>
Dim answer
answer=msgbox(&quot;Continue?&quot;,vbYesNo)
If answer=vbYes Then
MsgBox(&quot;Your answer was yes!&quot;)
ElseIf answer=vbNo Then
MsgBox(&quot;Your answer was no!&quot;)
End If
</script>

You could also use a browser detection script to see if their browser supports vbscript and use the regular Javascript &quot;OK,Cancel&quot; if it doesn't. Look here for more info:

 
Thanks adam0101 I was able to get that to work.. But the problem is, when you select yes or not the user would be sent to the next page. At the point the users selects yes or no, I want to stop them from continuing on if they choose no. How can I do that in vbscript?
 
Try this:

<script>
function conf(msg){
return (document.all ? vbConfirm(msg) : confirm(msg))
}
</script>
<script language=&quot;vbscript&quot;>
Function vbConfirm(msg)
If MsgBox(msg,vbYesNo)=vbYes Then
vbConfirm=True
Else
vbConfirm=False
End If
End Function
</script>
<a href=&quot;somePage.html&quot; onclick=&quot;return conf('Are you sure?')&quot;>Click Me</a>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top