0

im making a responsive website so when it is at mobile size the navigation turns into a jump menu, this is all fine and dandy!

but when is change pages on the jump menu whenever i get to another page the parent of the jump menu stays at the home page so i cant click back on the home page from another, how would i make it so say im on the home page and i click to go to the electrics page, on the electrics page the jump menu is ticked on electric?

p.s i cant change it on every page cos im pulling in the same nav bar on each page, below is the code im using at the moment

<form name="form" class="mob-nav">
          <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
            <option value="index.php">Home</option>
            <option value="how-it-works.php">How it works</option>
            <option value="gas.php">Gas</option>
            <option value="electric.php">Electric</option>
            <option value="telecoms.php">Telecoms</option>
            <option value="services.php">Services</option>
            <option value="contact.php">Contact</option>
          </select>
        </form>

heres a link to the site http://79.170.44.126/rkhconsultants.co.uk/

2 Answers 2

1

fixed it with some php

<?
        if ($PHP_SELF != '/rkhconsultants.co.uk/index.php')
        { $page1 = ''; } else { $page1 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/how-it-works.php')
        { $page2 = ''; } else { $page2 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/gas.php')
        { $page3 = ''; } else { $page3 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/electric.php')
        { $page4 = ''; } else { $page4 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/telecoms.php')
        { $page5 = ''; } else { $page5 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/services.php')
        { $page6 = ''; } else { $page6 = 'selected'; }
        if ($PHP_SELF != '/rkhconsultants.co.uk/contact.php')
        { $page7 = ''; } else { $page7 = 'selected'; }
    ?>

<form name="form" class="mob-nav">
          <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
            <option <?echo $page1;?> value="index.php">Home</option>
            <option <?echo $page2;?> value="how-it-works.php">How it works</option>
            <option <?echo $page3;?> value="gas.php">Gas</option>
            <option <?echo $page4;?> value="electric.php">Electric</option>
            <option <?echo $page5;?> value="telecoms.php">Telecoms</option>
            <option <?echo $page6;?> value="services.php">Services</option>
            <option <?echo $page7;?> value="contact.php">Contact</option>
          </select>
       </form>
Sign up to request clarification or add additional context in comments.

Comments

0

In short you need to add the selected tag inside of the option element

 <option selected value="electric.php">Electric</option>

So you will want to duplicate the code that is adding class active on your navigation via PHP.

1 Comment

cheers for telling me about the selected thing, i used that with some php to fix it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.