Change HTML class attribute using javascript
Jan 31, 2008 Noticias
Some readers asked to me how to change the class attribute of an HTML element using javascript. You can use setAttribute() in this way:
…where className is the name of class you want to assign to your html element with ID equal to “idElement”.
An example
Image you have a <div> element with a link which call a javascript function changeClass() to change the <div> class:
<a href=“javascript:changeClass()”>Change Class</a>
<script language=“javascript”>
function changeClass(){
document.getElementById(“idElement“).setAttribute(“class”, “myClass“);
}
</script>
Jan 31, 2008 Noticias
DAILY FOREX STRATEGY 1 FEB 2008 released 22.08 GMT click the chart
DAILY20PIP.COM ADVICE : WARNING U.S NONFARM PAYROLL AHEAD
SIGNAL VALID FROM 6.00 GMT - 18.00 GMT
RESULT PROFIT
Trade Ideas for Friday - BIDU, RFMD, CNXT, ADCT
Jan 31, 2008 Noticias
AC
Jordan Furlong’s Blog is Law21.ca
Jan 31, 2008 Noticias
The Canadian legal blogosphere elevated a couple notches in recent weeks with the addition of CBA National editor Jordan Furlong. After dipping his toes in over at Slaw, Jordan is now blogging full-time at Law21.ca.
Jordan is a smart guy, a prolific writer, and I can’t count the times I’ve been completely envious of the vision he offers. I can feel that law21 RSS subscriber count rising already!
Congrats Jordan on making the big plunge. And looking at the volume of content you’ve already generated, your post count should surpass mine in about three weeks. Nothing like making up for lost time…
Quickscribe Updates BC Legislation Manuals
Jan 31, 2008 Noticias
I received a note from BC Legislation Service Quickscribe this morning that a number of their manuals were updated for January, 2008. Those included:
February updates are also in the works, and should be released soon.
Confirmed: Google Hates Librarians
Jan 30, 2008 Noticias
See Librarian in Black, Cohen, Bradley and Abram.
Add me too… A 7 month summer break? tsk tsk Google. Shame on you!
Ah who are we kidding? We were lucking to get the invite. They were never going to show up and take us to the prom. Were they?
Jan 30, 2008 Noticias
DAILY FOREX STRATEGY 31 JAN 2008 released 10.26 pm D20P click the chart
DAILY20PIP.COM ADVICE : CHOPPY MARKET AHEAD
SIGNAL VALID FROM 6.00 am - 6.00 pm D20P trading time
RESULT PROFIT
Rambus shares spiked on the news
Jan 30, 2008 Noticias
ICO - The stock is approaching again the $6.11 level which typically acts as resistance, so keep an eye on her for a possible breakout.
AC
Tabbed search bar using CSS and Javascript
Jan 30, 2008 Noticias
This tutorial explains how to implement a simple tabbed search bar using CSS and a javascript function which set “active” the selected tab and changes the value of an hidden <input> element to set search options and execute your search only for all items related to the selected topic (for example: web, images, videos…).
Take a look at how it works
Download this tutorial
HTML code for tabs
I used a <ul> list with <li> element to implement tabs
<li id=“tab1″ class=“selected”><a href=“#” onclick=“javascript:setSearchOptions(1);”>Web</a></li>
<li id=“tab2″><a href=“#” onclick=“javascript:setSearchOptions(2);”>Images</a></li>
<li id=“tab3″><a href=“#” onclick=“javascript:setSearchOptions(3);”>Videos</a></li>
You can add other tabs simply adding new <li>elements using a progressive number for ID attribute (tab4, tab5, teab6…). Each tab call a javascript function setSearchOption() which set “active” the selected tab and set the value of the following hidden <input> field to enable search options:
When you submit the form (using PHP or another server side language), if is set the post variable related to this hidden field ($_POST['searchop'] for example) and this variable is equal to some value (an integer or a string), then you can execute a query instead of another one. For example if you select image tab, your query will execute the search only for images.
Javascript setSearchOptions() function
This is the function which set the active tab and change the value of the hidden input element:
/* Total Tabs above the input field (in this case there are 3 tabs: web, images, videos) */
tot_tab = 3;
tab = document.getElementById(‘tab’+idElement);
search_option = document.getElementById(’searchopt’);
for(i=1; i<=3; i++){
if(i==idElement){
/*set class for active tab */
tab.setAttribute(“class”,“selected”);
/*set value for the hidden input element */
search_option.value = idElement;
} else {
/*unset class for non active tabs */
document.getElementById(‘tab’+i).setAttribute(“class”,“”);
}
}
}
For more infos or questions contact me ![]()
Take a look at how it works
Download this tutorial
Interview with Steve Yegge on Rhino on Rails and more
Jan 29, 2008 Noticias
Last year, Steve Yegge posted about Rhino on Rails, his port of Ruby on Rails to the JavaScript language on the Rhino runtime. It garnered a slew of interest, and I have been wanting to talk to him in more detail about the project.
Fortunately, I happened to be at the Google Kirkland office and Steve graciously had time to spend talking about the framework. Steve is an entertaining chap, and manages to keep you interested with long blog entries, and did the same as I chatted with him.
In the conversation we cover the germination of the project, why Steve went ahead with the port, the side effects of JavaScript on the server, how Rhino will be implementing JavaScript 2 / ECMAScript 4 (with Google committing engineers to the project), the intent to open source RnR, and random thoughts from a language geek.
Give it a watch, and let us know if there are any other questions you would have liked to ask




