I need to make this code set "str" as "Recent" if the "str" got no value.
Right now i have to use this:
<form>
<select name="users" onChange="showUser(this.value)">
<option value="">Select album:</option>
<option value="Recent">Somealbumname</option>
</select>
</form>
but its really annoying to have to use the select, i want the code to load with the "str" as "Recent" if its not declared already.
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","xxxx/xxxx.php?q="+str,true);
xmlhttp.send();
}
</script>