/    Sign up×
Community /Pin to ProfileBookmark

Stop Propagation event after onchange Select!!!!

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>

[/CODE]

Thanks in advance for any help and suggestion OR a solution will be great?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@LeeUDec 03.2007 — Please don't double post. The other thread has been removed.
×

Success!

Help @abdkad2007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...