Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: Help Passing Variables to/from Popup Window

  1. #16
    swap out the alert for whatever function you want it to call... pretty simple. You can put any function as the final parameter of the confirm function.

    	'Accept Paypal Surcharge?', 
    	'<p>There will be a ' + rate + '% surcharge for using PayPal.</p><p><span class="keepTogether"><b>Product Total:</b> $' + total.toFixed(2) + '</span> &bull; <span class="keepTogether"><b>Total Charge:</b> $' + (total * (rate + 100) / 100).toFixed(2) + '</b></span></p><p>Please click the Accept button to authorize this charge.<br />Otherwise click the Decline button.</p>',
    Just replace 'alert' with whatever function you want to handle the result. Because of how it (or window.open if you went that route) works, you can' t simply 'wait for a result'; the joys of event driven programming.

  2. #17
    Join Date
    Apr 2013
    Got it! Thanks. Works fine now. Appreciate all your help.

  3. #18
    Join Date
    Apr 2013
    BTW, what's the purpose of the two 'true' parameters at the end of the handlerAdd function?

  4. #19
    Oops, you can lose those, that's left-over from when it was using my library. In the library the first one prevents event bubbling, the second one calls a code to make sure nothing gets selected accidentally.


    The standalone version is far simpler because it doesn't add a wrapping function to automatically do those, or do the e = e || window.event; var t = e.target || e.srcElement for you.

  5. #20
    Join Date
    Apr 2013
    Thanks, I was just wondering. Actually, I had hoped that they somehow controlled the buttons so I could use it as a more generic routine (a customized alert besides a customized confirm). Oh well, you can't have everything.

    Again, my thanks for your help.

  6. #21
    I was actually thinking along those lines -- expanding that code to let you specify a list of buttons, returning that button's text as the result instead of true/false.

    something like:

    dialogBox = function(title, message, buttons, handler)

    where buttons is an array of texts to put into the buttons. Might be even better to just pass it a single object:

    dialogBox = function(data)


    var data = {
    	title : 'dialog title',
    	message : '<p>Your message markup</p>',
    	buttons : [ 'Yes', 'No', 'Cancel' ],
    The object would be passed by reference lowering the memory use (in theory) and would be a bit clearer as to what's being declared for values.

    I might spend the time to put that together working as it could be useful for some of the stuff I'm working on as well -- both as a standalone, and as an example for my JavaScript library. I've got to fix the bugs my taking bad advice introduced to my library first, but when I get the more versatile version of this up and running I'll post a link to it here.

    I've also been playing with the idea of a full-on browser based windowing UI API, just for 'laughs'. Well, not entirely for laughs - I have an... odd idea I've been playing with.
    Last edited by deathshadow; 05-16-2014 at 10:26 AM.

  7. #22
    Join Date
    Apr 2013

    That would be great. Since I don't seem to be getting emails when you respond, could you please email me (robert_kline@earthlink.net) when the stand-alone version is ready? I definitely have a use for it.


  8. #23
    Join Date
    Apr 2013
    Hey deathshadow,

    I hope you're still monitoring this thread. I'm using your econfirm script for another project and have run into a minor problem. When the user clicks on one of the "popup window" buttons, they're returned to the top of the invoking webpage. Turns out this was true in the membership form application, but the page was so small, that it was almost unnoticeable. The new project page is much larger and I want the user to be returned to the place on the page where they clicked the link.

    The econfirm script is invoked with:
    Speaker: <a href="" onclick="getPayment();return false" onfocus="this.blur()">Click here</a> to learn about our special speaker.
    The javascript looks like this:
    function getPayment(){
        message = "Noted author, lecturer and button collector<p>Peggy Ann Osborne<p>Program will be presented via Skype from her home in Nova Scotia\n\n";
        confirm('Special Guest Presenter',message,getResults);
    function getResults(results){return false}
    I've tried a couple of things, including setting a tag, but it always goes to the top of the page (the page isn't reloaded, it just displays at the top).

    Any ideas?


  9. #24
    The only thing that would cause that is the # in the anchor -- which a proper 'prevent' method would stop from propagating.

    Right after the 'confirm' function, you'd want to add something like this:
    handlerAdd(confirmPaypal, 'click', function(e) {
    		'Accept Paypal Surcharge?', 
    				NOTE - this is one of the times JavaScript's lack of whitespace
    				neutral strings REALLY pisses me off
    		'<p>There will be a ' + rate + '% surcharge for using PayPal.</p><p><span class="keepTogether"><b>Product Total:</b> $' + total.toFixed(2) + '</span> &bull; <span class="keepTogether"><b>Total Charge:</b> $' + (total * (rate + 100) / 100).toFixed(2) + '</b></span></p><p>Please click the Accept button to authorize this charge.<br />Otherwise click the Decline button.</p>',
    	e.cancelBubble = true;
    	if (e.stopPropagation) e.stopPropagation();
    	if (e.preventDefault) e.preventDefault();
    	e.returnValue = false;
    }, true, true);
    though one thing I didn't point out, the href on that anchor should be changed to a verification URL -- so that scripting off the page still works. That's why for something like a FORM you'd attach the confirm to onsubmit, cancel the submit, then manually submit.

    Again, unwritten rule of JS - "If you can't make the page work without scripting FIRST, you likely have no business adding scripting to it!"

  10. #25
    Join Date
    Mar 2007
    Simplest answer really is to do like the majority of sites who trade online do it, you show this information as part of your trading terms and have that amount already added in to the total and have the page with a continue to payment or cancel order.

    I understand that you are trying to pass on your losses that you make from a paypal trade, you should consider how detrimental this could be and record the number of purchases vs the failures at the checkout stage.

    Your alternative is to already build in to your pricing structure a percentage and have no need for any additional costs.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11886 seconds
  • Memory Usage 2,950KB
  • Queries Executed 15 (?)
More Information
Template Usage (36):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (74):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates