0

My javascript function setHw is not called by pressing the return key in all of the following pages.
Please help.

<div id="rowPerPageDiv">
<form name="tagform" action="Hw.htm" method="post">
  <input type="hidden" name="currPage" value="0"/>
  Rows Per Page<input type="text" name="rowsPerPage" id="rowsPerPage" value="20" onsubmit="return setHw()"/>
  <input type="button" value="Apply" onClick="setHw()"><br>
</form>
</div>
<div id="rowPerPageDiv">
<form name="tagform">
  <input type="hidden" name="currPage" value="0"/>
  Rows Per Page<input type="text" name="rowsPerPage" id="rowsPerPage" value="20" onsubmit="return setHw()"/>
  <input type="button" value="Apply" onClick="setHw()"><br>
</form>
</div>
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

The "onsubmit" should be in the <form> tag - try that. If you want to catch the enter key being hit in a text field, you should use a function that checks the key being pressed on keyup/keydown, such as:

function enterKeyHit (e)
    {
    if (e && e.keyCode == 13)
        {
        return true;
        }
    else
        {
        return false;
        }
    }

<input type="text" name="rowsPerPage" id="rowsPerPage" value="20" onkeyup="if (enterKeyHit(event)) {setHw();}"/>

Edited by mike_2000_17: Fixed formatting

0
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="javascript">
function showDiv(e) {
	var unicode=e.keyCode? e.keyCode : e.charCode
	if (unicode==13){
		//your code
	}
}
</script>
</head>

<body>
<body onkeypress="showDiv(event)">
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.