Jump to content
php.lv forumi

menu select


ziedinjsh

Recommended Posts

Sveiki, man tāds jautājums.

 

Ja man ir šāda izvēlne

$page = (isset($_GET['page'])) ? $_GET['page'] : '';


echo "<a href='index.php'>Home</a>";
echo "<a href='index.php?page=info'>Info</a>";
echo "<a href='index.php?page=something'>Something</a>";

if($page == 'info'){
include "kkas.php";
}

if($page == 'something'){
include "kkas2.php";
}

 

kā lai es uztaisu lai rāda current.. es uzspiežu uz info un viņš paliek piem. bold vai kaut kā tā.. tas nebūtu tik svarīgi

 

bet kā lai uztaisa to kad viņš rāda tagad atvērto sadaļu?

 

Paldies jau iebriekš! :)

Edited by ziedinjsh
Link to comment
Share on other sites

Paldies! :) šitā es nebiju iedomājies, bet nu neiet kaut kā.

 

CSS:

/* menu */
.menu{
border:1px solid #000000;
float:left;
padding:5px;
margin-right:1px;
font-size:20px;
font-family:arial;
font-weight:bold;
cursor:pointer;
color:#000000;
}
.menu:hover{
background-color:#000000;
color:#ffffff;
}
.current{
background-color:#000000;
color:#cccccc;
}

 

PHP

$page = (isset($_GET['page'])) ? $_GET['page'] : '';



echo "<div onclick=\"location.href='index.php';\" class='menu' ".($page==""?" class='current'":"").">Sākums</div>";
echo "<div onclick=\"location.href='index.php?page=about';\" class='menu' ".($page=="about"?" class='current'":"").">Par mums</div>";
echo "<div onclick=\"location.href='index.php?page=biography';\" class='menu' ".($page=="biography"?" class='current'":"").">Biogrāfija</div>";
echo "<div onclick=\"location.href='index.php?page=contacts';\" class='menu' ".($page=="contacts"?" class='current'":"").">Kontakti</div>";









if ($page==''){
include "page.php";
}
if ($page=='about'){
include "about.php";
}
if($page=='biography'){
include "biography.php";
}
if($page=='contacts'){
include "contacts.php";
}


 

uzspiežot uz linku current nenostrādā..

Edited by ziedinjsh
Link to comment
Share on other sites

bļin, tur labākajā gadījumā sanāk divas class pēc kārtas... tb class="menu" class="current"

 

echo "<div onclick=\"location.href='index.php?page=about';\" class='menu".($page=='about'?" current":"")."'>Par mums</div>";

Link to comment
Share on other sites

salīdzini atšķirību.

 

<style type="text/css">
.x { color:red;}
.y { font-weight:bold;}
</style>
<p class="x" class="y">qwerty</p>
<p class="x y">qwerty</p>

 

Jebkurā gadījumā, abi nav labākais variants priekš menu.

Edited by Val
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...