Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 109,726 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,861 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Expanding Links

 
Reply to this topicStart new topic

Expanding Links

morcomm
post 21 Jul, 2008 - 11:27 PM
Post #1


New D.I.C Head

*
Joined: 28 Mar, 2008
Posts: 46


My Contributions


Hi,

Below is the code that I am using on a services page for an engineering company. It is working great.
I think the code explains itself, but what it basically does is when the header is clicked for each service, it will bring up a UL for subheadings below. There can be more than one level, thus the $moreone and $moretwo.
The problem that I am having with this is if I have scrolled down on the page, and then decide to click on the heading to expand it, it will shoot up to the top of the page again and I will have to scroll down to see what I have expanded.
Does anyone have a fix for this, or is there a totally different way of going about this?

CODE
<?php
    $moreone = $_GET['moreone'];
    $moretwo = $_GET['moretwo'];
    ?>
  
      <b><?php
      if ($moreone == "Water and Wastewater") echo "<a href='services_water.php?moreone='>";
      elseif ($moreone !== "Water and Wastewater")echo "<a href='services_water.php?moreone=Water and Wastewater'>";
      ?>Water and Wastewater</a></b>
        <ul>
        <?php
        if ($moreone == "Water and Wastewater") echo "<li>Treatment process design and plant optimisation assessments</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Asset condition assessments</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Pump station design and refurbishment</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Reticulation network design, system analysis and hydraulic modelling</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Large diameter pipeline design</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Reservoir optimization and design</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Water conservation and demand management</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Major dam design and river intakes</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Sewage reticulation design</li>";
        if ($moreone == "Water and Wastewater") echo "<li>Sewage pump station design</li>";
        ?>      
        </ul>
User is offlineProfile CardPM

Go to the top of the page


grimpirate
post 21 Jul, 2008 - 11:47 PM
Post #2


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 146



Thanked 3 times

Dream Kudos: 375
My Contributions


I suggest you use a named anchor to get to the most current click. Simply HTML thing you can do. Read more on it here.

Basically, wherever the new click occurs add in something like the following:

<a name="last">Whatever</a>

And then change the form's action attribute that you use to submit it to something like:

action="page.php#last"

Which will automatically scroll you to that link
User is offlineProfile CardPM

Go to the top of the page

morcomm
post 22 Jul, 2008 - 12:12 AM
Post #3


New D.I.C Head

*
Joined: 28 Mar, 2008
Posts: 46


My Contributions


QUOTE(grimpirate @ 21 Jul, 2008 - 11:47 PM) *

I suggest you use a named anchor to get to the most current click. Simply HTML thing you can do. Read more on it here.

Basically, wherever the new click occurs add in something like the following:

<a name="last">Whatever</a>

And then change the form's action attribute that you use to submit it to something like:

action="page.php#last"

Which will automatically scroll you to that link


I tried this. The problem with this is that the said links are at the bottom of the page, so when you expand the link, it still jumps and when you expand the next, it jumps again.

I need something that will expand, but not effect where you are on the page (smooth). I think this maybe can be done using Java, but I have tried to keep my site Java free. I also think that this could be done using CSS "display: none", but the points are going to be real lengthy and I would rather not have it load until it is called to.
If Java is the only way, then I will use it.
User is offlineProfile CardPM

Go to the top of the page

morcomm
post 22 Jul, 2008 - 10:47 PM
Post #4


New D.I.C Head

*
Joined: 28 Mar, 2008
Posts: 46


My Contributions


Is there no way of doing this, PHP server-side only. Or do I have to go Javascript?
User is offlineProfile CardPM

Go to the top of the page

William_Wilson
post 23 Jul, 2008 - 12:52 AM
Post #5


lost in compilation

Group Icon
Joined: 23 Dec, 2005
Posts: 3,564



Dream Kudos: 3275

Expert In: Java, C, Javascript

My Contributions


There are always solutions other than Java in web design.

How much data will you be loading? Is it that big of a deal to load it at page load?
User is offlineProfile CardPM

Go to the top of the page

morcomm
post 23 Jul, 2008 - 01:01 AM
Post #6


New D.I.C Head

*
Joined: 28 Mar, 2008
Posts: 46


My Contributions


It is big. It will consist of a UL and it will also have display a table that is six pages long printed A4.
Another thing is the client has instructed me to not use JS, flash or anything else that does not output plain HTML.
How about AJAX. I have never used it before, but I see it does update pages without a reload/refresh. I was looking at a math function that worked great, but I don't know how to alter it for my means.
I know AJAX is JS, but if the clients browser has JS disabled will the AJAX still work?
He says he wants to test the site on IE 3 when it is completed.
User is offlineProfile CardPM

Go to the top of the page

morcomm
post 23 Jul, 2008 - 04:12 AM
Post #7


New D.I.C Head

*
Joined: 28 Mar, 2008
Posts: 46


My Contributions


OK, I have gone Java, but would greatly prefer AJAX. This is my code

JAVA
CODE
<script language="javascript">
  function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }
</script>


PHP
CODE
   <p><b><a href="java script:;" onmousedown="toggleDiv('005');">Integrated Water Resource Management</a></b>
  <div id="005" style="display:none">
      <ul>
        <li>Institutional analysis and modelling </li>
        <li>International institutions for river basin management </li>
        <li>National institutions for water management</li>
        <li>Business process analysis and systems design </li>
        <li>Water management institutional support </li>
        <li>Stakeholder participation and consultation </li>
        <li>Conceptual modelling </li>
        <li>Capacity development</li>
      </ul>
  </div></p>


How can I make this app AJAX?
User is offlineProfile CardPM

Go to the top of the page

Moonbat
post 23 Jul, 2008 - 08:15 AM
Post #8


D.I.C Head

Group Icon
Joined: 30 Jun, 2008
Posts: 143



Thanked 9 times

Dream Kudos: 475
My Contributions


QUOTE(morcomm @ 23 Jul, 2008 - 04:12 AM) *
How can I make this app AJAX?

AJAX is just a combination of JavaScript and XML working together. It depends heavily on client-side (so if your client has a slow connection, it will load slow).

It might be Web 2.0, but I don't think it will be good in your situation.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/8/08 09:58AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month