views:

32

answers:

1

Is it possible to refresh a div, table or <tr>. Here no such data comes from database, its a simple error displaying block and value comes from Java-script.

Issue is that when an user inputs a value in textbox, value stored in that database and Successfully Stored Message comes on the Screen.

Then again at the same page, user try to enter wrong value then error shows in that block, but the previous value remains ie "Successfully Stored Message".

An suggestion ???

+1  A: 

Yes, you can easily clear an element of it's children (i.e. a success message) when some event occurs. In your case, the event would be entering data in a textbox. Assuming the following markup:

<input type="text" id="textbox" name="textbox"/>
<div id="message">
    Successfully Stored Message
</div>

When you detect another event on your textbox, you just empty the <div id="message"> as follows:

var textbox = document.getElementById('textbox');
textbox.onchange = function(){

    // Do some test to determine if you should clear #message

    // Get your #message container and remove all its children
    var message = document.getElementById('message');
    while(message.hasChildNodes()){
        message.removeChild(message.firstChild);   
    }       
};

Change the input's value in this example to see it in action.

Pat