Target specific tab with hyperlink from other page on same website - php

I've got a page (documents.php) that contains four tabs, the 1st tab is set as the default and opens when one browses to documents.php
I need to be able to target tabs 2, 3 and 4 directly from hyperlinks on my index.php and a JavaScript menu that appears on all pages on the site.
Example:
Tab 3 on documents.php contains "archived documents".
On Index.php I want to place a link called "Click here to go to Archived documents" and when someone clicks on it it must take them to documents.php but automatically go to Tab 3 which is "archived documents" and not go to the default 1st Tab.
Here is the coding I am using to create the Tabs and would like to only modify this at most (and not re-invent the wheel by using jQuery or other technology and re-write the tabs on this and other pages):
HTML:
<ul>
<li class="current">General Documents</li>
<li>Circulars</li>
<li>Newsletters</li>
<li>Archived Documents</li>
</ul>
Javascript:
<script>
$(document).ready(function(){
$(".tabs li").click(function() {
$(this).parent().parent().find(".tab-content").hide();
var selected_tab = $(this).find("a").attr("href");
$(selected_tab).fadeIn();
$(this).parent().find("li").removeClass('current');
$(this).addClass("current");
return false;
});
});</script>
Then there's some CSS in an external style sheet that formats the Tabs, their borders, background etc.
CSS Formatting:
.tabs ul{
list-style:none;
display:block;
margin:0px;
padding:0px;
z-index:99;
position:relative;
}
.tabs li {
float:left;
display:block;
border-top:#E5E5E5 1px solid;
border-left:#E5E5E5 1px solid;
border-right:#E5E5E5 1px solid;
border-top-left-radius:4px;
border-top-right-radius:4px;
position:relative;
z-index:999;
color: #444444;
padding: 4px 8px 4px 8px;
margin: 0px 6px 0px 0px;
background: #e7e7e7 url(/assets/images/common/bg.png) repeat-x;
}
.tabs li:hover {
/*If you want hover effects on tabs put your css here*/
}
.tabs li a {
display:block;
color:#323234;
outline:none;
}
.tabs li.current {
border-bottom:#DD6E27 2px solid;
outline:none;
}
.tab-content {
display:none;
clear:both;
min-height: 120px;
border-top-left-radius:0px;
border-top-right-radius:4px;
border-bottom-left-radius:4px;
border-bottom-right-radius:4px;
color:#444444;
background:#fefefe url(/assets/images/common/bg.png) repeat-x;
border: 1px solid #E5E5E5;
overflow:hidden;
padding:15px;
}
.tab-content:first-child {
display: block;
}

Pass the # value url like http://example.com#tabs3 .Then use like this in your document ready.
$(document).ready(function(){
var hash = window.location.hash;
$('#'+ hash).addClass("current");
$(".tabs li").click(function() {
$(this).parent().parent().find(".tab-content").hide();
var selected_tab = $(this).find("a").attr("href");
$(selected_tab).fadeIn();
$(this).parent().find("li").removeClass('current');
$(this).addClass("current");
return false;
});
});

Related

css have a listbox i need it to on select neither changes text color as active or inactive, focus or not focused. its click add, click add

I have a listbox, I need it to on select neither change text color as active or inactive, focus or not focused. Its click add, click add. On this one the text stays white on select, and turns black when click out of the listbox. I need it to stay red and only background to change when its clicked, to show it was clicked, then just go back to black. (Ive been at this for a couple days before asking, might have errors in the code after rewriting it so many times.)
<select onclick="" class="sometext" name="sometext" size="5">
<?php
$sql = "select * FROM mom WHERE type='feedme'";
foreach ($dblsm->query($sql) as $row){
echo "<option value=$row[id]>$row[title]</option>";
/* Option values are added by looping through the array */
}
?>
</select>
css
/* turn it off completely */
select:active, select:hover, select:focus {
outline: none;
}
select option:hover {
background: linear-gradient(#a81b1b, #000000);
background-color: #000000 !important; /* for IE */
color: #a81b1b !important;
outline: none;
}
select option:checked, select option:active, select option:disabled {
background: linear-gradient(#000000, #000000);
background-color: #000000 !important; /* for IE */
color: #a81b1b !important;
}
.sometext::-webkit-scrollbar {
width: 8px;
}
/* Track */
.sometext::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* Handle */
.sometext::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: #a81b1b;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
.sometext {
color: #a81b1b;
background-color: black;
width: 225px;
border: 3px inset;
border-color: #a81b1b;
scrollbar-face-color: #367CD2;
scrollbar-shadow-color: #FFFFFF;
scrollbar-highlight-color: #a81b1b;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #FFFFFF;
scrollbar-arrow-color: #FFFFFF;
}
So, if I understand your question better now from your comments, I'm not sure how to accomplish this with the default options of a form's select box. What I did come up with for you is a way to get a similar outcome with plain ol' html/js/css and hopefully you can adapt this to your needs:
<html>
<head>
</head>
<body>
<div>
<ul class="redhue">
<li onClick="changeSelectionTo(this)">1</li>
<li onClick="changeSelectionTo(this)">2</li>
<li onClick="changeSelectionTo(this)">3</li>
</ul>
</div>
<script>
var currentlySelected;
function changeSelectionTo(item) {
if(currentlySelected){
currentlySelected.classList.remove("selected");
}
currentlySelected = item;
item.classList.add("selected");
console.log(item.innerText);
}
</script>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li:hover,
.selected {
background: linear-gradient(#a81b1b, #000000);
background-color: #000000; /* for IE */
color: #a81b1b;
}
.redhue {
color: #a81b1b;
background-color: black;
width: 225px;
border: 3px inset;
border-color: #a81b1b;
list-style: none;
}
</style>
</body>
</html>
I left the console.log statement to show how to retrieve the list item's value for whatever you would need it for... Hope this helps!

How to show add to cart button after hover through product box in woocommerce?

I have a problem when making a wordpress theme integrated with woocommerce like cannot show "add to cart" button when hovering a cursor in product box and only show when hovering a cursor to bottom in product box like GIF below:
woocommerce.css
.woocommerce ul.products li.product .button {
margin: 1em 0 3px 0.3em;
}
.woocommerce a.button {
/* font-size: 100%; */
/* margin: 0; */
/* line-height: 1; */
/* cursor: pointer; */
position: relative;
font-family: inherit;
text-decoration: none;
overflow: visible;
padding: 0.618em 1.75em;
font-weight: 700;
/* border-radius: 3px; */
/* left: auto; */
color: transparent;
background-color: transparent;
/* border: 0; */
/* white-space: nowrap; */
/* display: inline-block; */
/* background-image: none; */
/* box-shadow: none; */
/* -webkit-box-shadow: none; */
/* text-shadow: none; */
}
.woocommerce a.button:hover {
background-color: #f37020;
text-decoration: none;
color: #fff;
background-image: none;
}
.woocommerce ul.products li:hover {
border: 3px solid;
border-color: #f37020;
}
How I can fix it?
UPDATED (Dec 11,2015):
Its my URL link: http://dev.galerigadget.com/shop/
Obviously your "add to cart" button is only displaying when you hover the lower part of the box. That indicates only the bottom area is linked. Your "a" element might need to be "display:block" so it covers the entire block inside the brown rule. Hard to tell without seeing the actual site. Can you post URL?
AFTER EXAMINING YOUR CODE, HERE IS WHAT IS HAPPENING
The add-to-cart link is there, even when not hovered.
You do not see it b/c the CSS includes:
color: transparent;
background-color: transparent;
I would remove those parameters so the button is visible in gray and white. Looks nice and tells the user where to click to purchase the item.
You still have the hover effect that changes the button color to brown, but now the user clearly sees where to put their cursor.
If you want the button 'hidden' until the box is hovered, and then turn brown when hovering the box, add this to your CSS:
li:hover a.add_to_cart_button {
background-color: #f37020;
text-decoration: none;
color: #fff;
background-image: none;
}
Here is an example
$(document).ready(function () {
$(document).on('mouseenter', '.divbutton', function () {
$(this).find(":button").show();
}).on('mouseleave', '.divbutton', function () {
$(this).find(":button").hide();
});
});
.divbutton {
height: 140px;
background: #0000ff;
width:180px;
}
button{
padding: 4px;
text-align: center;
margin-top: 109px;
margin-left: 7px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="divbutton" ">
<button type="button" style="display: none;">ADD TO CART</button>
</div>
Or If you want to use only CSS
button {
display: none; /* Hide button */
}
.divbutton:hover button {
display: block; /* On :hover of div show button */
}

Buttons with mouse over and out function

Check this url please http://x2t.com/262032
You can see how does facebook button work right side of navigation menu.
This code works with this button.
CSS
div.social-wrapper {
float: right;
text-align: right;
font-size: 15px;
font-weight: bold;
margin: 11px 15px 0px 0px;
}
div.social-wrapper-text {
margin-bottom: 10px;
}
div.social-icon:first-child {
margin-left: 0px;
}
div.social-icon {
float: left;
margin-left: 11px;
opacity: 0.55;
filter: alpha(opacity=55);
cursor: pointer;
}
I need the code for two facebook buttons with mouse over and out function.
On mouse over guest will see for example white FB button and on mouse over black one.
How to do this?
<button class="class_of_button"> like us on facebook </button>
.class_of_button {
background: url('source of fb image');
}
.class_of_button:hover {
background: url('source of black fb image');
}
Here my personal solution for this:
HTML:
<div class="social-icon">
<a href="CHANGE THIS LINK TO YOUR ONE">
<img src="MOUSE_OFF.jpg"></img>
<img src="MOUSE_ON.jpg"></img>
</a>
</div>
CSS:
<style type="text/css">
div.social-icon
{
width: 600px; /* Width of IMG, TO BE CHANGED *
height: 800px; /* Height of IMG, TO BE CHANGED *
}
div.social-icon img:nth-child(2)
{
display: none;
}
div.social-icon img:first-child
{
display: block;
}
div.social-icon:hover img:nth-child(2)
{
display: block;
}
div.social-icon:hover img:first-child
{
display: none;
}
</style>
Just put the CSS into the
and the html where you would have placed your button.
And don't forget to change the mentioned values in the css and html.
And yes: You have to create the images yourself, so show yourself some Paint skillz~

Making hover color stay if link is active

I'm working on a website using PHP, HTML and CSS. Currently in my navigation bar, I've set the background color to be grey. When the user hovers over the navigation bar, each link gets a blue background, however when I click the link, the background color goes back to grey. How do I make the hover color blue stay if that particular link is active.
This is the code for my navigation bar.
<tr>
<td width="800" height="54">
<div id="nav" >
<ax><b><font face="Arial" ><a style="text-decoration: none; color:#303030" href="index.php" >HOME</a></font></b></ax>
<bx><b><font face="arial" ><a style="text-decoration: none; color:#303030" href="edituser.php?own=y">IT</a></font></b></bx>
<cx><b><font face="arial" ><a style="text-decoration: none; color:#303030" href="newsevents.php">HUMAN RESOURCE</a></font></b></cx>
<dx><b><font face="arial" ><a style="text-decoration: none; color:#303030" href="industries.php">PROCUREMENT</a></font></b></dx>
<ex><b><font face="arial" size="1"><a style="text-decoration: none; color:#303030" href="http://www.csmphilippines.com/aboutus.html">FINANCE</a></font></b></ex>
<fx><b><font face="arial" ><a style="text-decoration: none; color:#303030" href="hact.php">HACT</a></font></b></fx>
</div>
</td>
This is the code for my CSS
#nav {
text-decoration:none;
padding-bottom:10px;
border-bottom:none;
width:
}
#nav ax {
display:inline;
padding:15px;
padding-left:31px;
padding-right:28px;
background-color:#ececec;
text-decoration:none;
}
#nav bx {
display:inline;
padding:15px;
padding-left:45px;
padding-right:45px;
background-color:#ececec;
text-decoration:none;
}
#nav cx {
display:inline;
padding:15px;
padding-left:45px;
padding-right:45px;
background-color:#ececec;
text-decoration:none;
}
#nav dx {
display:inline;
padding:15px;
padding-left:45px;
padding-right:45px;
background-color:#ececec;
text-decoration:none;
}
#nav ex {
display:inline;
padding:15px;
padding-left:53px;
padding-right:53px;
background-color:#ececec;
text-decoration:none;
}
#nav fx {
display:inline;
padding:15px;
padding-left:30px;
padding-right:30px;
background-color:#ececec;
text-decoration:none;
}
#nav ax:hover {
background-image:url(images/tabbackit.jpg);
background-repeat:repeat-x;
height:900px;
}
#nav bx:hover {
background-image:url(images/tabbackit.jpg);
background-repeat:repeat-x;
height:900px;
}
#nav cx:hover {
background-image:url(images/tabback.jpg);
background-repeat:repeat-x;
height:900px;
}
#nav dx:hover {
background-image:url(images/tabbackproc.jpg);
background-repeat:repeat-x;
height:900px;
}
#nav ex:hover {
background-image:url(images/tabbackfin.jpg);
background-repeat:repeat-x;
height:900px;
}
#nav fx:hover {
background-image:url(images/tabbackhact.jpg);
background-repeat:repeat-x;
height:900px;
}
The way I do this is to give each page its own id in the body tag:
<body id="pgAbout">
Then have a seperate id for each menu item:
<li id="mnuAbout">
Using CSS you can style the link now for the page you're on:
#pgAbout #mnuAbout,
#pgOther #mnuOther
{
/* Styles here */
}
Here's a brief demo
Update
Here's another demo using your own HTML to clarify how it works a bit.
A simple thing you could do is use the same stylesheet for all your pages, but use different CSS classes to highlight the corresponding link on each page. For example, on index.php, use the .active class to highlight the Home link.
Since you're new (as you said), let's break it down:
Use the same CSS for all the pages. However, define two CSS classes for the navbar elements: one is the .regular state, the other is the .active state. In every page, give the link corresponding to that page the active class, while the other links remain in the regular class.
But then, would you want it to remain a link?
It's simple, Just put following code
For example,
On Home page, put following code in HEAD
<style type="text/css">
#nav ax{
background-image:url(images/tabbackit.jpg);
background-repeat:repeat-x;
}
</style>

How do I make elements flow horizontally instead of vertically?

I have a link after an image in my xhtml. The browser automatically puts a return character after the image so that the link is below the image. I want the link to be beside the image. How do I modify the CSS/XHTML for this?
PHP generates it like this(example code)
echo "<img class = \"c\" src=\"http:\/\/www.facebook.com\/favicon.ico\" alt=\"\"\/>";
echo "<a name = \"a1\" class = \"b\" href = \"$ass_array[url]\">$ass_array[name]</a>";
CSS
img.c
{
display:??;
}
a.b
{
color:#000088;
padding-top:2px;
padding-bottom:2px;
display:block;
width:100%;
border-bottom:1px solid #cccccc;
}
See: http://jsfiddle.net/thirtydot/vgnAa/
CSS:
.c {
display: block;
float: left;
margin-top: 4px;
margin-right: 4px;
}
.b {
color:#000088;
padding-top:2px;
padding-bottom:2px;
display:block;
border-bottom:1px solid #cccccc;
overflow: hidden;
}
Either float: left, float: right depending which side you want the link to be. Apply that to both, and make sure to have a clear div after.
This way you can still have that display:block on .b.
"float:left;" for both elements will work

Categories