/    Sign up×
Community /Pin to ProfileBookmark

controling a button click event

Hi Guys

I am developing a form in which a window should popup when the user abondons the page.
This page contains 3 buttons.
1) Submit button
2) cancel button
3) goback button.

This popup window should popup in all the cases except the user clicks on
submit button.
I have written a javascript function which will popup a window.
But I dont know how to control as per the event.
Any help will be appreciated.

Here is the javascript function
@@@@@@@@@@@@@@@@

[CODE]function SurveyPopup() {
if (window.showModalDialog)
{
Surveywindow=window.showModalDialog(‘Popup.htm’,’Surveywindow’,’center:yes;dialogWidth:300px;dialogHeight:200px’)
}
else
{
Surveywindow=window.open(“Popup.htm”,”Surveywindow”,”location=1,width=300,height=200,menubar=0,resizable=0,modal=yes”)
}
}
}

</script>

</head>
<body onunload=”SurveyPopup()”>[/CODE]

@@@@@@@@@@@@@@@@@@@@

Thanks in advance

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelDec 18.2007 — You must be new for forums(?). ? -'New' member's posts, until the earn a 'trusted status' (several dozen posts maybe, or a bit more??), are automatically held for "moderation" by either a moderator, a sup-moderator or administrator. This is to eliminate the benign, friendly SPAM posts.

New posts by new members don't 'automatically appear' when you hit the "submit" or "post" button until a 'trusted status' is attained, so it is unnecessary to [I]re-post[/I] your post 2, 3 or 4 times (as you tried ? ), thinking that you were being snubbed.

I moderated & approved your thread/post, and deleted the other three attempts as they were 'duplicate posts'.

Welcome to WD, enjoy! ?
Copy linkTweet thisAlerts:
@KorDec 19.2007 — Try:
<i>
</i>&lt;form onsubmit="window.onunload=function(){null}"&gt;
Copy linkTweet thisAlerts:
@ken_rgrauthorDec 20.2007 — Hi Kor

Unfortunately its not working.

I made some changes to my code.

Can you look into to it tell where i am doing wrong.

Here is modified code

@@@@@@@@@@@@@@@@

function SurveyPopup()

{


if(document.form1.Submit1.value == true) {

alert(document.form1.Submit1);

if (window.showModalDialog)

{

Surveywindow=window.showModalDialog('Popup.htm','Surveywindow','center:yes;dialogWidth:300px;dialogHeight:200px')


}

else

{

Surveywindow=window.open("Popup.htm","Surveywindow","location=1,width=300,height=200,menubar=0,resizable=0,modal=yes")

}

}

}

</script>

</head>

<body onunload="SurveyPopup()">
Copy linkTweet thisAlerts:
@KorDec 21.2007 — when you submit something you change the session, thus you can not preserve the javascript changes. Still, you may use a cookie or you may control the process via a server-side application (php...asp...)
Copy linkTweet thisAlerts:
@ken_rgrauthorDec 21.2007 — Hi Kor

Thanks for your reply.

Really I didnt understand your answer. Its all happening in one page.

What it is to do with session.

What I really want is the SurveyPopup() funtion shouldnot work

when the user clicks on Submit button. Thats it.

is there any way can we disable the function for Submit button.??

Thanks in advance.
Copy linkTweet thisAlerts:
@KorDec 21.2007 — The general idea is that you can not solve your problem with javascript, becuase when you submit something you change the session. Javascript is a client-side language, thus its changes are not persistent between sessions, except maybe on using cookies. Another solution is to use a server-side control of the session. You need a server-side programmer for that.
Copy linkTweet thisAlerts:
@ken_rgrauthorDec 21.2007 — Hi Kor

Thanks for your reply.

All my program works on client side.

When the user abondons the sign up form then the survey popup

should show. I put my javascript function in <body> tag.

so its popping up everytime even on Submit click also.

What I want is it should not popup when user clicks on Submit button.(Submitting is moving away from the current form, means unload event is

generated)

All this happens on client side. So Do I really need Server side programming

for this??? I think If I find a way to disable the function on Submit click

it will solve the problem. I guess.

Please advice me.

Thanks
×

Success!

Help @ken_rgr 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...