Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: [RESOLVED] redirect to DIV ID in same function

  1. #1
    Join Date
    Apr 2009

    resolved [RESOLVED] redirect to DIV ID in same function

    PHP Code:
    function jdisplay2($getall,$getwhat,$noneofwhat,$whathappened,$optionfour)
    "<div style='margin-left:auto; margin-right:auto; width:90%;height:103px;position:relative; clear:left;border:1px solid #000000;background-color: rgba($c1,$c2,$c3, 0.4);font-weight:bold'>".$displayit."</div> 
                    <div style='float:right;'><div style='text-align:right;'>"
    .$whathappened." ".$budsince."&nbsp;</div>
                            <div style='text-align:right;'><a class='inline' href=\"#message_content_"
                            <div style='text-align:right;'><a class='inline' href=\"#wink_content_"
                            <div style='text-align:right;'><a class='inline' href=\"#save_content_"
    .$userinfo->userid."\">Save Profile</a>&nbsp;</div>
                            <div style='text-align:right;'><a class='inline' href=\"#dunno_content_"
                            <!-- This contains the hidden content for inline calls -->
                            <div style='display:none'>
                                <div id='message_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                I wanna put a form here to message "
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
                                <div id='wink_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                I wanna make this to pick a WINK to give to"
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
                                <div id='save_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                This will pop-up to show you saved "
    .$userinfo->username."'s profile 
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
                                <div id='dunno_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                Not sure what will go here but its with "
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
    This creates a set of links for each user in my MYSQL. Everything but one issue works perfectly. This issue is when I hover or click on the links Message, Wink, Save Profile, or Remove (if the value of $optionfour is 'remove') it wants to go to localhost/#message_content_"some number".
    This script is located in a PHP function on localhost/include/lightbox/jdisplay.php.

    How can I redirect the href link correctly?

  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA
    Your links are setup that way. What do you want them to do??
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  3. #3
    Join Date
    Apr 2009
    I need it to stay within the php function to operate the tag properly

  4. #4
    Join Date
    Jul 2013
    Voorheesville NY USA
    Sorry don't understand.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  5. #5
    As Ginerhm said:

    What are you EXPECTING them to do? You put a # in there, it's not going to reload the page. What's the PHP that's supposed to recieve those requests look like? did you mean to do that as GETdata thus?


    Setting that aside, mein gott that markup is terrifying... endless pointless DIV, classes, and nothing remotely resembling semantic markup... much less all that presentation inlined in the HTML that makes it harder to work with.

    Here's a tip, if you have a bunch of elements getting the same class in a row inside a parent, leverage selectors to nab them instead of wasting markup on it... likewise if you're using the STYLE attribute in all but the rarest of cases, you're making life harder in the long run.

    Likewise use echo instead of print since you don't need/aren't using the return result, and stop using the slower double quotes, you'll use less escapes if you use singles for PHP. I'd also say stop using string addition as it's slower and less predictable than comma delimits on output. See this little gem:

    function a() { echo 'test'; }
    echo ' This is a ' . a() . '<br />'; // outputs 'test This is a '
    echo ' This is a ', a(), '<br />'; // outputs ' This is a test'
    It's a fun head scratcher.

    In any case, this is (guessing slightly) what you should probably have for code on that:

    	echo '
    		<div class="eventSection">
    			<h2>', $displayit, '</h2>
    			<p class="whatHappened">
    				', $whathappened, ' ', $budsince, '
    				<li><a href="#message_content_', $userinfo->userid, '">Message</a></li>
    				<li><a href="#wink_content_', $userinfo->userid, '">Wink</a></li>
    				<li><a href="#save_content_', $userinfo->userid, '>Save Profile</a></li>
    				<li><a href="#dunno_content_', $userinfo->userid, '>".$optionfour."</a></li>
    			<div class="hiddenSections">
    				<div id="message_content_', $userinfo->userid, '"> 
    						I wanna put a form here to message ', $userinfo->username, '
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				<div id='wink_content_', $userinfo->userid, '"> 
    						I wanna make this to pick a WINK to give to', $userinfo->username, '
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				<div id='save_content_', $userinfo->userid, '"> 
    						This will pop-up to show you saved ', $userinfo->username, '\'s profile  
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				<div id='dunno_content_', $userinfo->userid, '"> 
    						Not sure what will go here but its with ', $userinfo->username, '
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    			<!-- .hiddenSections --></div> 
    		<!-- .eventSection --></div>';
    The heading level would have to be adjusted to suit the page -- but notice how much easier it is to work with and read without all the pointless screen-only style in the markup and using single quotes instead of doubles and comma delimits instead of string addition? EVERYTHING else goes in your stylesheet where it belongs. EVEN IN TESTING having all that extra style (THAT HAS NO BUSINESS IN THE HTML IN THE FIRST PLACE) in the way just makes life harder -- I don't get why so many developers seem to think otherwise.

    Though in rewriting it, I THINK I'm understanding what you're trying to do -- but you're overriding the outer 'hidden' how exactly? It LOOKS like this might be a job for ':target' on modern browsers but I'd have to see what you are actually trying to accomplish to say more.

    I just don't think we're seeing enough of your end goal.

  6. #6
    Join Date
    Apr 2009
    The script is partially running at http://albertaxchange.com/include/lightbox/index.php. The only glitches there are the lack of images which has nothing to do with its purpose.
    Clicking on the links at the right (Message, Come On, Save Profile, and Remove) opens a lightbox popup specific to THAT user's info (you'll notice the name listed in the popup matches the username in that link's window)
    The problem is that when I try to access lightbox/index.php from the PHP function designed to display this in a DIV, I get the entire page accurately BUT hovering the links shows it will go to http://albertaxchange.com/#message (for example)
    I have tried AJAX to summon this page from the appropriate function, tried just simple 'include', tried moving the DIVs after "This contains the hidden content for inline calls --> " to a page of their own and changed the href to "href=\"DIVpage.php#message_content_".$userinfo->userid."\">" but nothing seems to work the way I want.
    I need this page somehow in the PHP function jdisplay due to other functions sending strings to this one.
    Hopefully seeing it explains better.

  7. #7
    Join Date
    Apr 2009
    Just for the record so no one thinks I'm a noob developer, the extra styling instead of using a style sheet is strictly for testing purposes. It is necessary so I can edit the style without refreshing the entire site. It is very time consuming starting from the index page and clicking several links to get to see if the color is right. So I style this way, then add those styles to the stylesheet once its perfect.

  8. #8
    Wait - your complaint is that the anchors are doing what anchors do and how they're SUPPOSED to work? REALLY? I wouldn't be sweating that; in fact bypassing it would be at the bottom of any concerns I had... in fact I'm a bit shocked you're even noticing/worrying about that.

    If it REALLY bothers you, you could put a TITLE on those anchors -- but beware some browsers will then show the title AND the url, instead of just the title... the behavior varies wildly from browser to browser.

    Oh, and since you'd have to refresh to get markup changes anyways, why is having the CSS separate an issue? Not certain I follow your reasoning on that... especially the "starting out on the index page and clicking several links" part; that really leaves me scratching my head going "just what are you doing?!?"

    BTW, your dynamic fonts inside those fixed height containers are blowing out of their parents. It's why you generally don't fix the height of content wrappers; that height:103px; is completely broken here... though it LOOKS like what you really wanted was float wrapping.

    Here's a screencap:

    That's why you usually don't fix the height of things.
    Last edited by deathshadow; 07-03-2014 at 04:59 AM.

  9. #9
    Join Date
    Apr 2009
    Did you actually read the issue or just decide to reply meaninglessly? Yes in the link I gave the anchors work. No the anchors do not work when the code is in a PHP function. Instead of trying to look like you know what you are doing by spouting off lengthy meaningless replies, read the entire issue. I need the script (that works solo) run from a PHP function (where the anchors fail). First you jump all over my styling and use of double quotes. Then you jump over my fixed font size. Neither are the issue. If you cant understand the issue, I'll gladly go thru it step by step for you.

  10. #10
    Join Date
    Apr 2009
    I have stripped down the code as to not distract deathshadow from the actual issue


    This works properly as expected.

    How do I get it to work exactly like this from something like the following

    PHP Code:
    //this function will be on http://albertaxchange.com/include/_MyStuff.php
    function PLEASE_WORK()
    Last edited by killinspre; 07-03-2014 at 09:21 AM.

  11. #11
    First, how you expected us to decipher that was what you were asking from what you posted? Still not sure I'm even understanding what you're asking.

    Second, are you requiring from a separate domain or something? Require operates on the local filesystem, NOT http.

    Third, you should probably have () on that require since 'loose functions' are allegedly going away soon.


    ... and you are aware that an include will path to where it's included FROM, not it's actual file location, right? If the .php file you are calling require from is in another directory, ALL your links in that 'require' should be relative accordingly.

    Never seen someone try to use include or require with http before -- that should NOT be allowed to work.

  12. #12
    Join Date
    Jul 2013
    Voorheesville NY USA
    I don't understand the statement "anchors do not work when the code is in a PHP function". HTML NEVER WORKS "in a php function"!

    And - if you really want help here don't tread on the people who are actually trying to not only understand your php and html and attempts at styling as well as your use of English to describe your intents and wishes. Apparently none of the many viewers of your post understand your English enough to even make the attempts that we have made.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  13. #13
    Join Date
    Apr 2009
    To both deathshadow and ginerjm, Neither have you have offered any advice on this topic because you both admit to not understanding the issue. And yet neither of you refrain from posting. Why? As ginerjm kindly stated, many viewers with no attempts to assist. I'm guessing because they couldn't help and decided to keep quiet instead of critiquing something they do not understand for one reason or another. Deathshadow, you have complained about punctuation and stylesheets, never once offering a solution to the problem. And now you are mentioning parenthesis for an issue that MAY happen? And ginerjm, now you pipe in about my English? If you can't contribute then back off and leave to postings to those that can. Stop flooding my topic with useless posts and let knowledgeable people assist those in need.

    Now back to my actual topic, I need to run this -> http://albertaxchange.com/include/lightbox/ from a php function without losing the anchors in this ->

    PHP Code:
    <div class="hiddenSections">
    div id="message_content_', $userinfo->userid, '"
    I wanna put a form here to message ', $userinfo->username, '
    class="ajax" href="ajax.html">Click here to load new content</a>
    div id='wink_content_'$userinfo->userid'"> 
                            I wanna make this to pick a WINK to give to'
                        <a class="ajax" href="ajax.html">Click here to load new content</a>
                    <div id='
    save_content_', $userinfo->userid, '"> 
                            This will pop-up to show you saved ', 
    $userinfo->username, '\'s profile  
                        <a class="
    ajax" href="ajax.html">Click here to load new content</a>
                    <div id='dunno_content_', 
    $userinfo->userid, '"
    Not sure what will go here but its with ', $userinfo->username, '
    class="ajax" href="ajax.html">Click here to load new content</a>
    As my example shows it works perfectly when run on its own but when I try to execute the script from a PHP function I lose the 'popup' of the hidden DIVs

  14. #14
    Quote Originally Posted by killinspre View Post
    And yet neither of you refrain from posting. Why?
    Because we like to help, we keep asking you for clarification you fail to provide, and maybe while we're in here help you fix all the other problems that make it harder to diagnose and will bite you in the backside sooner than later.

    I actually think I may have hit the problem on the head, but you failed to grasp it... Are you sure the directory of the include (which is treated as http root) is compatible with your relative links?

    Though I think your broken / strange terminology is why we're not quite understanding what you mean. For example:

    Quote Originally Posted by killinspre View Post
    As my example shows it works perfectly when run on its own but when I try to execute the script from a PHP function I lose the 'popup' of the hidden DIVs
    Execute what script? you talk about scripting, then a PHP function? What do they even have to do with each-other?!? When you include it how / where are you including it. We can't help you without seeing where it DOESN'T WORK because it's probably how you're including it that's the problem.

    Something you've flat out failed to show! WHAT PHP function? WHAT SCRIPT? You're using terms together in a way that doesn't even make sense! Hence Ginerjm's crack about your engrish ... and your code...

    But apparently you don't actually want to be helped, cannot clearly form a coherent explanation, and get your panties in a wad when people try to provide actual assistance.

    Have fun with that.

  15. #15
    Join Date
    Jul 2013
    Voorheesville NY USA
    I agree with Deathshadow wholeheartedly. We have both asked you specific questions that you have sidestepped. How you expect a FUNCTION to execute a script I don't understand. I won't even ask a question about it, since I know you hate that.

    And I still don't see forum members clambering aboard this topic. Me - I getting off this topic. You just don't understand attempts to help when they do show up.

    Good luck.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

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.12315 seconds
  • Memory Usage 3,071KB
  • Queries Executed 15 (?)
More Information
Template Usage (38):
  • (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
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)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
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)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