Change HTML class attribute using javascript

If you are a JavaScript newbie this post helps you to implement a simple code to change the class for HTML elements.

Some readers asked to me how to change the class attribute of an HTML element using javascript. You can use setAttribute() in this way:

document.getElementById(idElement).setAttribute(“class”,className);

…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:

<div id=“myElement”>Welcome on my site!</div>
<a href=“javascript:changeClass()”&gtChange Class</a>
<script language=“javascript”>
function changeClass(){
document.getElementById(idElement).setAttribute(“class”,myClass);
}
</script>

DAILY FOREX STRATEGY 1 FEB 2008 released 22.08 GMT click the chart

D20P SELL A GBP/USD 1.9859
take profit 1.9839
stoploss 1.9889
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

Chart courtesy of stockcharts

ADCT - The stock should pause around its resistance of $15 after recent rally in share price, however chart is now more Bullish than was before. The recent action in ADCT is very promising. Last week the stock aggressively moved off its lows of $12.63 to rally nearly to $15 on respectable volume, so keep an eye for a possible breakout over $15 too.
Chart courtesy of stockcharts

CNXT looks like it is getting ready to move. The stock broke through its 20-day moving average on today session, this was the first signal that I was looking for since a while. Looking at the daily chart, Conexant looks very good here, especially if market attempts a rally again.
Chart courtesy of stockcharts

RFMD is a stock to watch closely tomorrow. Company announced that its Board of Directors has authorized the repurchase of up to $150 million of its outstanding common stock over the next 24 months. On the other hand company also reported its earnings, RF Micro Devices swung to a loss in its fiscal third quarter, and said results in the current quarter will lower as excess inventory of cell phone chips weigh the company down. A mixed bag. Techinally, stock bounced back from recent lows, and chart is now showing some signals of improvement through some indicators, like MACD and RSI. I like the way the stock bounced back from the share consolidation activity, and it may be time to believe in stock again. I like the repurchase program, especially considering the actual market capitalization of stock. Wait for tomorrow reaction.
Chart courtesy of stockcharts
BIDU shares surged today gaining nearly 8% to $279.95. Stock has refused to go down in $250 area. By looking at the chart, you can see that the stock has found a strong support level around the $248-250 range, on its 200 day moving average. So, after today rally, It looks like bidu has found some buyers to test its downtrend at line around $310 as is mentioned in the chart.

Disclaimer : Trading stocks involves risk, this information should not be viewed as trading recommendations.The charts provided here are not meant for investment purposes and only serve as technical examples.

That’s All. Have a great evening !!!

AC

Jordan Furlong’s Blog is Law21.ca

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

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

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?

DAILY FOREX STRATEGY 31 JAN 2008 released 10.26 pm D20P click the chart

D20P SELL A GBP/USD 1.9866
take profit 1.9846
stoploss 1.9896
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

Chart courtesy of stockcharts

Rambus – Early in the morning I was surprised with bombastic news for RMBS. According to Bloomberg, Rambus the designer of chips of chips for Sony Corp’s Playstation video game console, might collect royalties of as much as $10 bln, six times its market value, by winning a seven year fight with Hynix Semiconductor. After claiming the world’s second largest memory chip maker infringed on patents it owned, Rambus won a $133.4 mln award in 2006. To collect, it must now win a trial next month over the South Korean manufacturer’s claim that the Los Altos, California-based company illegally used information obtained at industry meetings in the 90s to get the patents. WOW this is huge men…..I’m now in, prepared for any kind of situation. This could be a money machine $$$$. Technically stock is now in a Bullish mode, stock price is above 20,50 and 200 daily moving average, also MACD back again above 0 indicating a Bullish market.High relative volume during this movement is another bullish indication that the stock will continue higher.
Chart courtesy of stockcharts

Keep an eye on CHIC to see if tomorrow stock will confirm intraday breakout.
Chart courtesy of stockcharts

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.

Chart courtesy of stockcharts
Looking at above chart, it shows that RIMM is in a downtrend that began in November. The key point of this analyze is to show that Research in motion is moving in a clear downward channel. Well, when this happen, there are two ways to play such a pattern. First, you can basically short the stock for the period of the pattern. Second, you can trade aggressively shorting when the stock reaches the top of the channel and buying when it reaches the lower bound. So, I think that both options can work fine as long as you pay attention, however you should be very attention for a possible break of the trend. So, looking at RIMM, stock has found a nice support level around $90, and is gaining some strength to move up according to the indicators, like MACD and RSI. The MACD is showing a positive divergence, after which the MACD made a bullish crossover. So, if you are shorting this stock since awhile, pay attention to these factors.

Disclaimer : Trading stocks involves risk, this information should not be viewed as trading recommendations.The charts provided here are not meant for investment purposes and only serve as technical examples.

That’s All. Have a great evening !!!

AC

Tabbed search bar using CSS and Javascript

Some lines of JavaScript code can help you to add nice effects to improve some features of your websites.

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

<ul class=“search-options”>
<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:

<input type=“hidden” name=“searchopt” id=“searchopt” />

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:

function setSearchOptions(idElement){
/* 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

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