views:

64

answers:

2

Hello,

I have Ajax page where I get search response inside textarea.

Here is the code

<form onSubmit="checkDomain();return false;" id="ajaxDomainForm" action="">
<input name="domain" type="text" id="domain" onKeyUp="checkForChange();" maxlength="255">
<textarea name="domainsAvailableInput" id="domainsAvailable" readonly="readonly"></textarea>
<div id='whatDomainDiv' style="font-weight:bold;display:none;">Domain</div>
<div id='isAvailableDiv' style="font-size:5em;display:none;">?</div>
</form>

What I want is to hide <textarea> until & unless it has some responded value in it.

How can achieve this using jQuery?

Thanks

A: 

On success ajax call you have to call a method. There you can say display:block for this text area. And you have to send a response message from the server. That message can be keep inside the text area.

Multiplexer
+1  A: 
jQuery(document).ready(function () {
    if (jQuery('#domainsAvailable').val() == '') {
        jQuery('#domainsAvailable').hide();
    }
});

This will hide your text area initially on page load.

Again when in your ajax response you get the text. you will have to write in your success callback.

jQuery('#domainsAvailable').show();

sushil bharwani
@sushil : Thanks. Your ajax success callback trick worked.
MANnDAaR