Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old November 27th, 2002, 03:11 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Options on page exit(only for the brave!! not because it's hard it's just a bit long)

Hi all:
We have this problem that we cannot solve, if anybody can help it'll be great...

We have a window with a text box with some default value inside and a submit button, when the user alters the default text in anyway and then clicks the submit button, the title field in the window will indicate there's a change and he/she will be prompt with another pop-up window(note: NOT window.prompt or wondow.confirm kind) asking if user wants to keep what is typed in the text box, uswer has a choice of "yes", "no" and "cancel", however if the user leave the text box untouched and press submit button, no window will pop up to ask the user.

Here's what's "supposed" to happen in each case:

case "yes" : pop up window will close and user will be left with the same page and things in input box will also be left as user has changed it, after this happens, if the user click submit again without changing the text box, nothing will come up as the new text has become the default text.

case "no": pop up window will close and user will be left with the original values in the text box BEFORE user alters it the first time.

case "cancel": pop up window will close and user will be left with input box same as the "yes" case but should the user press the submit button again the pop-up window will still show up(as only cancel is clicked).

Now... i know i've bored you enough.... here's the problem....

we had codings for two different windows, one for the pop-up window and one for the 'parent' window that calls it, we managed to link them in a way that the "yes" case works alright... but then we're stuck in the "no" case... here's our code....

<html>
<head>
<script type="text/javascript">
changed = false;
function show()
{
parent.document.title="Warning: The content in this page has been altered."
changed = true;
}
//***taken out the openwindow() and closewindow() functions to save space on here...
function promptUser(value)
{
if(value == 't')
{
if (changed)
openwindow();
}
if(value == 'y')
closewindow();
if(value == 'n')
{
closewindow();
opener.document.my.reset();
}
if(value == 'c')
// closewindow(); //****stuck afterwards
}
</script>
</head>
<body>
<form name="my" action="Project6(test).php" method="POST">
Submit Box: <br>
<?php
if ($userinput == "")
echo('<input name="userinput" onkeyup="show()" size="45" value="Quick fox" >');
else
echo('<input name="userinput" onkeyup="show()" size="45" value="'.$userinput.'" >');
?>
<br><br>
<INPUT TYPE="submit" NAME="submitButton" VALUE="Submit" onClick= "promptUser('t')">
</form>
</body>
</html>



if somebody can tell us what part is wrong it'll be VERY GREAT!!! we've been stuck on this for so long.. it could be because there's something REALLY WRONG we've done since the beginning that we couldn't see.....please help!

Bo&Vic

Reply With Quote
  #2  
Old November 29th, 2002, 04:23 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Options on page exit(only for the brave!! not because it's hard it's just a bit long)

Bo & Vic:

Hi guys. (or guy and girl, could be victoria, vicky)

I don't know exactly why you want a custom confirmation dialog. To me, the standard one works well enough. It is also much easier to code. Also, the logic of your confirm dialog seems strange. Why have a cancel option? Surely it would be fine for people to press OK because it doesn't automatically submit the form if you say OK. They could then make updates anyway. On the other hand, if you wanted pressing OK in the dialog to submit the form, you would need a custom one.

I have never tried to use a custom dialog box, but it seems easy enough. My code seems to work fine. The only problem is I haven't found out how to position the dialog on the screen. I tried using an absolutely positioned div as a dialog, but it has issues...

Some things about your code:

When you press an arrow key in the text box, it tells you that the content is modified, when it isn't yet.

Using onclick on the submit button, instead of onsubmit on the form. Notice I used "return promptUser();".

Relying on register_globals. If you are using PHP4, you should be doing it the new way. Check out the php code section.

After the dialog has returned, the title was not being reset.

Hope this helps.


*** bovic.php ***
php Code:
Original - php Code
  1.  
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. changed = false;
  6. oldtitle = '';
  7. confirmbusy = false;
  8.  
  9. function show()
  10. {
  11.     if ((!changed) && (document.my.userinput.value != textorig))
  12.     {
  13.         oldtitle = document.title;
  14.         document.title="Warning: The content in this page has been altered."
  15.         changed = true;
  16.     }
  17. }
  18.  
  19. function promptUser()
  20. {
  21.     if (confirmbusy) return false;
  22.     if (!changed) return true;
  23.     //I haven't worked out how to position the window on the screen yet.
  24.     window.open('confirm.html', 'confirm', 'height=120,width=180');
  25.     confirmbusy = true;
  26.     return false;
  27. }
  28. </script>
  29. </head>
  30. <body>
  31. <form name="my" action="Project6(test).php" method="POST" onsubmit="return promptUser();">
  32. Submit Box: <br>
  33. <?php
  34. if (!array_key_exists('userinput', $_POST)) // or get or session or whatever
  35. echo('<input name="userinput" onkeyup="show();" size="45" value="Quick fox" >'
  36.    .'<script type="text/javascript">textorig = "Quick fox"</script>');
  37. else
  38. echo('<input name="userinput" onkeyup="show();" size="45" value="'.$_POST['userinput']
  39.    .'"><script type="text/javascript">textorig = "'.$_POST['userinput'].'"</script>');
  40. ?>
  41. <br><br>
  42. <INPUT TYPE="submit" NAME="submitButton" VALUE="Submit">
  43. </form>
  44. </body>
  45. </html>


*** confirm.html ***
php Code:
Original - php Code
  1.  
  2. <html>
  3. <head>
  4. <title>Sample Confirm Dialog</title>
  5. </head>
  6. <script type="text/javascript">
  7.  
  8. function confirmyes()
  9. {
  10.     opener.textorig = opener.document.my.userinput.value;
  11.     opener.changed = false;
  12.     opener.document.title = opener.oldtitle;
  13.     opener.confirmbusy = false;
  14.     window.close();
  15. }
  16.  
  17. function confirmno()
  18. {
  19.     opener.document.my.userinput.value = opener.textorig;
  20.     opener.changed = false;
  21.     opener.document.title = opener.oldtitle;
  22.     opener.confirmbusy = false;
  23.     window.close();
  24. }
  25.  
  26. function confirmcancel()
  27. {
  28.     opener.confirmbusy = false;
  29.     window.close();
  30. }
  31.  
  32. </script>
  33. <body>
  34. <form name=neversubmitted method=POST action=#>
  35. <p>Would you like to accept your changes?</p>
  36. <input type=button name=yes value=Yes onclick="confirmyes();">
  37. <input type=button name=no value=No onclick="confirmno();">
  38. <input type=button name=cancel value=Cancel onclick="confirmcancel();">
  39. </form>
  40. </body>
  41. </html>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Options on page exit(only for the brave!! not because it's hard it's just a bit long)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway