Tuesday, 13 January 2009

javascript: enter to execute


<html>

<head>

<script type="text/javascript">

    function getrefno(reno, helperMsg){

        if(reno.value.length == 0){

            alert(helperMsg);

            elem.focus();

            return false;

        }else{

            window.location = "http://www.gigibride.co.uk/gallery/category/image-galleries/"+reno.value;

            return true;

        }

    }





function entertoget(e){

var code;

if (!e) var e = window.event;

if (e.keyCode) code = e.keyCode;

else if (e.which) code = e.which;



var character = String.fromCharCode(code);



if(code==13){

var refn=document.getElementById('ref');

var address = refn.value;

alert(address);

}



}



</script>

</head>

<body>





<form>



Reference: <input type='text' id='ref' onkeypress="javascript:entertoget(event);" value='gigigallery' />



<input type='button' onclick="javascript:getrefno(document.getElementById('ref'), 'Please Enter Your Ref No.');" value='Get My Photos' />



</form>

</body>

</html>

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter