Get URL Variables/parameters values With JavaScript


javscript function ///
//name = Pass URl parameter
function getParameterByName(name) {
alert(name);
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
var result= match && decodeURIComponent(match[1].replace(/\+/g, ' '));
alert(result);
}

// ]]>


and buttun onclick event onclick=”javascript:getParameterByName(‘utm_source’);”
URL = javascript_get_parameter.html?utm_source=massmail&utm_medium=email&utm_campaign=21-feb-2015

Multiselect , Tags , Autosuggest using core javascript DOM element

<script>
function selectIngredient(select)
{
var option = select.options[select.selectedIndex];
var ul = select.parentNode.getElementsByTagName(‘ul’)[0];

var choices = ul.getElementsByTagName(‘input’);
for (var i = 0; i < choices.length; i++)
if (choices[i].value == option.value)
return;

var li = document.createElement(‘li’);
var input = document.createElement(‘input’);
var text = document.createTextNode(option.firstChild.data);

input.type = ‘hidden’;
input.name = ‘ingredients[]’;
input.value = option.value;

li.appendChild(input);
li.appendChild(text);
li.setAttribute(‘onclick’, ‘this.parentNode.removeChild(this);’);

ul.appendChild(li);
}
</script> <ul>

</ul>
<select onchange=”selectIngredient(this);”>
<option value=”Cheese”>Cheese</option>
<option value=”Olives”>Olives</option>
<option value=”Pepperoni”>Pepperoni</option>

</select>