It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Display Result on Same Page??

Display Result on Same Page??

Postby hiyatran on Sat Oct 02, 2010 4:45 pm

When I hit the submit button, the result are display on a new page. how do I force it to stay on the same page, here's my code.

Code: Select all
<HTML>
<HEAD>
<TITLE>Test Input</TITLE>

<script type="text/javascript">
function addtext() {
   var newtext = document.myform.inputbox.value;
   document.writeln(newtext);
}
</script>

</HEAD>

<BODY>

<FORM NAME="myform">Enter something in the box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE="">
<INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()">
</FORM>


</BODY>
</HTML>


any comments or suggestions would be greatly appreciated.
hiyatran
 
Posts: 18
Joined: Mon Jun 21, 2010 1:53 am

Re: Display Result on Same Page??

Postby HotNoob on Sat Oct 02, 2010 5:05 pm

Document.writeline is an obsolete function, it doesnt do what it's supposed to do, so instead, you will have to do this:

Code: Select all
<HTML>
  <HEAD>
    <TITLE>Test Input</TITLE>

    <script type="text/javascript">
      function addtext()
      {
         var newtext = document.myform.inputbox.value;
         document.getElementById('returnValue').innerHTML = newtext;
      }
    </script>
  </HEAD>
  <BODY>
    <FORM NAME="myform">Enter something in the box: <BR>
      <INPUT TYPE="text" NAME="inputbox" VALUE="">
      <INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()">
    </FORM>
    <DIV id=returnValue>
    </DIV>
  </BODY>
</HTML>
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am


Who is online

Users browsing this forum: No registered users and 3 guests