1.

Solve : JavaScript Problem?

Answer»

Can anyone give me the solution of below PROBLEM.....
i have created FOLLOWING html web-page..
the problem is that when i CLICK transfer button it copy data from box 1 to box 2.Thats fine....
but when i click clear button it does not empty the value of box 1.
Why, if there is an error in my coding please WRITE the solution soon, please write the easiest methods to do it, i have my first try on javascript.

<html>
<head>
<script>
document.writeln(hifi())
function hifi()
   {
         var time = new Date
         var avinash = "The current Time is " +  time.getHours() + ":" + time.getMinutes() 
         return(avinash)
    }
</script>
<script>
function fool()
   {
      var access
      
      access = document.form1.Text.value ;
      document.form1.Text2.value = access ;
   }

function clearthis()
        {
               clear(document.form1.Text.value);
         }
</script>
</head>
<body>
<h2 align="center">
!!!!Content Mover!!!!
</h2>
<h3>Instructions to use the application:-</h3>
<p>Firstly you have to enter data in BOX1 then, Click the Transfer button to transfer data from Box1 to Box2.</p>
<p>Use Clear button to clear text from box 1</p>
<BUTTON onclick="fool()">Transfer</BUTTON>
<BUTTON onclick="clearthis()">Clear</BUTTON>
<form name="form1">
Box1:<input maxlength="100" type="text" name="Text" value="" >
Box2:<input maxlength="100" type="text" name="Text2" value="" >
</form>
</body>
</html>

please run this script in your own browser and give solution immediately Here is the fix. It assigns the value of null space of '' to Box 1 by this method below, so the Clear function clears Box 1's contents through replacement with null space. You can even pass this null space to the box 2 with the transfer:

function clearthis()
        {
               clear(document.form1.Text.value ='');
               
         }


Code: [Select]<html>
<head>
<script>
document.writeln(hifi())
function hifi()
   {
         var time = new Date
         var avinash = "The current Time is " +  time.getHours() + ":" + time.getMinutes() 
         return(avinash)
    }
</script>
<script>
function fool()
   {
      var access
     
      access = document.form1.Text.value ;
      document.form1.Text2.value = access ;
   }

function clearthis()
        {
               clear(document.form1.Text.value ='');
               
         }
</script>
</head>
<body>
<h2 align="center">
!!!!Content Mover!!!!
</h2>
<h3>Instructions to use the application:-</h3>
<p>Firstly you have to enter data in Box1 then, Click the Transfer button to transfer data from Box1 to Box2.</p>
<p>Use Clear button to clear text from box 1</p>
<BUTTON onclick="fool()">Transfer</BUTTON>
<BUTTON onclick="clearthis()">Clear</BUTTON>
<form name="form1">
Box1:<input maxlength="100" type="text" name="Text" value="" >
Box2:<input maxlength="100" type="text" name="Text2" value="" >
</form>
</body>
</html>



Discussion

No Comment Found