Archive for the ‘javascript’ Category

Javascript split numbers from string

Hi,
From time to time you have a string that contains numbers and letters and you need to split them.
This is very easy to do using Javascript.
Lets say you have this  string:
var string  = “due_date47″;
to create to vars that one will have “due_date” as value and the other “47″ do this:
<script type=”text/javascript”>var field = “due_date37″;

var [...]

How to change form target using Javascript?

Well sometime you need that. If you have two submit buttons, one you want to open in the same page and the other on a new one.
Just use this:
document.getElementById(form_id).target= “_blank”;
Hope it helps!

How to create a blinking effect using Javascript

Hi all,
Some time when you use Ajax to do an action you want to give the user an

indication that the action took place and everything went well. For example you have a text field that onchange action calls for a Javascript function that takes the value, sends it to PHP file, [...]

Small tip to get the status of checkbox

Hi all,
It  took me long time to get it… I wanted to check if a checkbox was checked or not.
So I used:
var checkbox = document.getElementById(&quot;checkbox_id&quot;).value;
Wrong! Wrong! Wrong!
the right way is:
var checkbox = document.getElementById(&quot;checkbox_id&quot;).checked;
which return true or false. Minor details wasted me lots of time…
Admin

Javascript element value

Hi all,
For beginners this could be helpful – How to get the value of each element in your page using Javascript?
Lets say you have <div id=”newid”></div>
use this:
var element_value = document.getElementById(&quot;newid&quot;).value;
Hope it helps!