www.webdeveloper.com
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
    Posts
    35

    resolved [RESOLVED] redirect to DIV ID in same function

    PHP Code:
    function jdisplay2($getall,$getwhat,$noneofwhat,$whathappened,$optionfour)
    {....
                    print
    "<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_"
    .$userinfo->userid."\">Message</a>&nbsp;</div>
                            <div style='text-align:right;'><a class='inline' href=\"#wink_content_"
    .$userinfo->userid."\">Wink</a>&nbsp;</div>
                            <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_"
    .$userinfo->userid."\">".$optionfour."</a>&nbsp;</div>
                            <!-- 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 "
    .$userinfo->username."
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
                                </div>
                                <div id='wink_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                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></p>
                                </div>
                                <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>
                                <div id='dunno_content_"
    .$userinfo->userid."' style='padding:10px; background:#fff;'>
                                Not sure what will go here but its with "
    .$userinfo->username."
                                <a class=\"ajax\" href=\"ajax.html\">Click here to load new content</a></p>
                                </div>
                            </div>
                    </div>"
    ;
    ...} 
    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
    Location
    Voorheesville NY USA
    Posts
    752
    Your links are setup that way. What do you want them to do??
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


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

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

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

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


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

  5. #5
    Join Date
    May 2014
    Posts
    936
    As Ginerhm said:
    href=\"#message_content_".$userinfo->userid."\"

    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?

    href=\"?message_content_".$userinfo->userid."\"

    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:

    Code:
    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:

    Code:
    	echo '
    		
    		<div class="eventSection">
    		
    			<h2>', $displayit, '</h2>
    		
    			<p class="whatHappened">
    				', $whathappened, ' ', $budsince, '
    			</p>
    			
    			<ul>
    				<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>
    			</ul>
    			
    			<div class="hiddenSections">
    			
    				<div id="message_content_', $userinfo->userid, '"> 
    					<p>
    						I wanna put a form here to message ', $userinfo->username, '
    					</p> 
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				</div>
    				
    				<div id='wink_content_', $userinfo->userid, '"> 
    					<p>
    						I wanna make this to pick a WINK to give to', $userinfo->username, '
    					</p>
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				</div>
    				
    				<div id='save_content_', $userinfo->userid, '"> 
    					<p>
    						This will pop-up to show you saved ', $userinfo->username, '\'s profile  
    					</p>
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				</div>
    				
    				<div id='dunno_content_', $userinfo->userid, '"> 
    					<p>
    						Not sure what will go here but its with ', $userinfo->username, '
    					</p>
    					<a class="ajax" href="ajax.html">Click here to load new content</a>
    				</div>
    				
    			<!-- .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.
    Java is to JavaScript as Ham is to Hamburger.

  6. #6
    Join Date
    Apr 2009
    Posts
    35
    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
    Posts
    35
    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
    Join Date
    May 2014
    Posts
    936
    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:
    http://www.cutcodedown.com/for_other...pre/broken.jpg

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

  9. #9
    Join Date
    Apr 2009
    Posts
    35
    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
    Posts
    35
    I have stripped down the code as to not distract deathshadow from the actual issue

    http://albertaxchange.com/include/lightbox/

    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()
        {
            require 
    'http://albertaxchange.com/include/lightbox/index.php';
        } 
    Last edited by killinspre; 07-03-2014 at 09:21 AM.

  11. #11
    Join Date
    May 2014
    Posts
    936
    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.

    require('include/lightbox/index.php');

    ... 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.
    Java is to JavaScript as Ham is to Hamburger.

  12. #12
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    752
    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.
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


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

  13. #13
    Join Date
    Apr 2009
    Posts
    35
    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, '"
                        <
    p>
                            
    I wanna put a form here to message ', $userinfo->username, '
                        
    </p
                        <
    class="ajax" href="ajax.html">Click here to load new content</a>
                    </
    div>
                    
                    <
    div id='wink_content_'$userinfo->userid'"> 
                        <p>
                            I wanna make this to pick a WINK to give to'
    $userinfo->username'
                        </p>
                        <a class="ajax" href="ajax.html">Click here to load new content</a>
                    </div>
                    
                    <div id='
    save_content_', $userinfo->userid, '"> 
                        <p>
                            This will pop-up to show you saved ', 
    $userinfo->username, '\'s profile  
                        </p>
                        <a class="
    ajax" href="ajax.html">Click here to load new content</a>
                    </div>
                    
                    <div id='dunno_content_', 
    $userinfo->userid, '"
                        <
    p>
                            
    Not sure what will go here but its with ', $userinfo->username, '
                        
    </p>
                        <
    class="ajax" href="ajax.html">Click here to load new content</a>
                    </
    div
    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
    Join Date
    May 2014
    Posts
    936
    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.
    Java is to JavaScript as Ham is to Hamburger.

  15. #15
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    752
    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.
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    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



Recent Articles