Tag Archives: javascript

Processing bar example code

When the “search” button is pressed, it shows the “Search processing. Please wait…”

until the browser shows “bestsellers.jsp”.

<div id=”search_simple”>     

<form id=”form1″ name=”form1″ method=”post” action=”bestsellers.jsp”

    <button name=”submit” type=”submit”>Search</button>

<div id=”processingbar” style=”display:none”>
 <h3><font color=”red”>Search processing. Please wait…</font></h3>

javascript code:

  function showProcessingBar()
     document.getElementById(“search_simple”).style.display = “none”;

     document.getElementById(“processingbar”).style.display = “block”;

     return true; // you must return true otherwise the form will not be submitted


document.URL has been deprecated

document.URL has been deprecated

My old code “document.URL = location.href + ‘&sortby=2’;” stops working.

It’s said that document.URL has been deprecated.

I change it to “document.location.href = “bestsellers.jsp?sortby=2″;”. It works just fine.

Use javascript to determine if the string is a positive Integer


<input type=”text” size=”1″ onKeyPress=”onlynumbers(this.value);” onMouseOut=”onlynumbers(this.value);”></input>

//if the string includes non-number character, isNaN() will return true. Just note that the code “parseInt() == NaN” isn’t right here.
var str_value = 0;
function onlynumbers(str_value) {
  if (isNaN(parseInt(str_value,10))) {
    alert(‘Warning: it’s not a positive integer。’);