Results 1 to 6 of 6

Thread: Passing variable from a link to an iframe in the receiving page

  1. #1
    Join Date
    Jun 2012

    Talking Passing variable from a link to an iframe in the receiving page

    The title may not explain it very well but it's best I can think of.
    In simple terms, I have 20 or so links like this one:

    each one where the "plan_id" is the only difference.

    Can I set each link up on their respective pages so that I can just have a simple querystring (ie. my-page-name.html?41745 or my-page-name.html?36906, etc) that will pass the number from the query string of the web address to the iframe that the form would load up in?

    If so, how would I go about doing this? I have researched into jquery methods but none seem to work and I tried this:

    "http://potternet.duoservers.com/?action=f_order&plan_id=<?PHP ECHO $_SERVER['QUERY_STRING']; ?>&css_file=http://www.potternet.net/css/form.css&otype="
    but it also fails to work.

    Is there a PHP code I can place into the head of my page to "$GET" the querystring and then get the iframe to load up with the correct information each time?

    Should you need a better explanation, let me know and I will see what I can do. cheers
    Last edited by PotterNet; 06-18-2012 at 04:28 AM.

  2. #2
    Join Date
    Jan 2009
    I would suggest reading up on GET.

  3. #3
    Join Date
    May 2012
    of my page to "$GET" the querystring and the
    it's $_GET not $GET ;-)

  4. #4
    Join Date
    Aug 2006
    you could also use innerHTML to dynamically rewrite the info into a div on the page instead of using an iframe.

    you could also have all the plans hardcoded in the html but hidden, and use javascript/jquery/css to toggle which is visible and which is hidden as the user

    you can also create several images of the different plans and use javscript to swap
    the source of the image to the relavant image as the click

  5. #5
    Join Date
    May 2011
    so I thought i'd have a play with this and ended up throwing this together:

    HTML Code:
    	<style type="text/css">
    	.iframe {style frame here}
    	<div id="changethis"></div>                                       <!-- this div will hold the iframe -->
    	<script type="text/javascript">
    		var iframe="";
    		if (location.search != "") {
    			var x = location.search.substr(1).split(";")        // this grabs your query string and makes it = x
    		iframe=iframe + ("<iframe class='iframe' src='http://potternet.duoservers.com/" + x + "'></iframe>");     // this puts the html for the iframe together
    		document.getElementById("changethis").innerHTML=iframe;                                                            // this loads it to the page
    What do you think? workable?
    Last edited by damndaewoo; 06-20-2012 at 05:01 PM.

  6. #6
    Join Date
    Aug 2006
    that'll probably work, but if you only have a small amount of plans to display, i think had coding them into hidden divs right in the page and using javascript to make them visible would be faster, you'd just hide all bu the one you want to show and when they clicked another plan it would hide them all again and then only make the plan selected visible, you could stack them all on top of each other like a deck of cards using css positioning or move them from off the left side of the screen into position while at the same time hiding or moving the others offscreen to the left or top like -1024px to the left or top, but this would work fine too especially if you have a lot of plans.

    since you already have about 20 pages of plans to display, just make a function that would pass the filename of the plan you want to load into the iframe...

    if your iframe code has an id of plan:

    <iframe id="plans" src="about:blank" width="400" height="400" frameborder="0" scrolling="no"></iframe>

    function loadPlan(plan_id){
    document.getElementByID('plans').src = 'http://potternet.duoservers.com/plans/' + plan_id + '.html';

    then you'd just supply the file name without the htm/html/php extension right in the link like this:

    <a href="javascript: loadPlan(36906)">Plan 1</a>
    <a href="javascript: loadPlan(36901)">Plan 2</a>

    then you'd just need to make sure that you have files named 36906.html and 36901.html
    on your server in the 'plans' directory. if the files exist they'll load, otherwise you'd likely get a 404 error in the iframe, and you can't use javascript to detect if a file exists or not unless you use ajax to check first.

    unless you are planning on having *a lot* of plans, again, i'd just hardcode them all into the page and use javascript + css to toggle their positions and visibility on the page.

    you can also use jquery's load function to load the contents of pages into the current page into a div for example, but not with an iframe.

    so you see, too many ways to skin this cat

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.09601 seconds
  • Memory Usage 2,906KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (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
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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 (72):
  • 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
  • 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