HI All, ?
This issue is driving crazy? and I’ll be waiting a hero from you to help me out with this.
Actually I want a warning message to appear if I change a select and tell me if I select continue so I can go ahead to the link of in the selected option OR cancel stop the event to go through and keep the previous selected option selected.
My code appears down. Actually when I press continue it works fine on the select But the cancel Doesn’t it always goes ahead and doesn’t stop eventhough i am using the “stopPropagation(e)” method
I have include a button and link. The continue and cancel Work fine on those but on change the select the cancel doesn’t work?
Any suggestion and help ? ?
[CODE]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>testing</title>
<!– Dependency –>
<script type=”text/javascript” src=”http://yui.yahooapis.com/2.3.1/build/yahoo/yahoo-min.js” ></script>
<!– Event source file –>
<script type=”text/javascript” src=”http://yui.yahooapis.com/2.3.1/build/event/event-min.js” ></script>
<script language=”javascript”>
YAHOO.namespace(“example.container”);
function fnCallback(e) {
var ok = confirm(“Are you welling to continue? “);
if(ok)
{
return true;
}
else
{
YAHOO.util.Event.preventDefault(e);
YAHOO.util.Event.stopPropagation(e);
return false;
}
}
function init() {
buttons = document.getElementsByTagName(“button”);
for (var i = 0; i < buttons.length; i++){
var oElementb = buttons.item(i);
YAHOO.util.Event.addListener(oElementb, “click”, fnCallback);
}
selects = document.getElementsByTagName(“select”);
for (var i = 0; i < selects.length; i++){
var oElements = selects.item(i);
YAHOO.util.Event.addListener(oElements, “change”, fnCallback);
}
links = document.getElementsByTagName(“a”);
for (var i = 0; i < links.length; i++){
var oElementl = links.item(i);
YAHOO.util.Event.addListener(oElementl, “click”, fnCallback);
}
}
YAHOO.util.Event.onDOMReady(init);
</script>
</head>
<body>
Choose a mail Type:
<select onchange=”window.location.href=this.options[this.selectedIndex].value”>
<option VALUE=”http://gmail.com”>Gmail</option>
<option VALUE=”http://www.hotmail.com”>Hotmail</option>
<option VALUE=”http://www.yahoo.com”>Yahoo!</option>
</select>
<br/>
<button id=”mybutton”>Push Me</button>
<br/>
<a href=”http://www.yahoo.com”>This is a link to yahoo</a>
</body>
</html>
Thanks in advance for any help and suggestion OR a solution will be great?