tags:

views:

43

answers:

5

Hello,

I want to set the value of a textbox to null via jquery. I tried

 onclick="$('#c_album').val('TEST VALUE');" at the submit button

$('input#c_album').val('hello'); - in the script section

Appreciate assitance

Thanks Dave

[edit]-- this is the code i am using

$('#submit').bind('click',(function(){
        $('#src_box').val('hello');
    });
A: 
rahul
does not work for some reason, tried that too :(
dave
Can you provide more code for this?
rahul
@pulse: its a search box, now when the user clicks the search button, he is presented with his search and the search text box value should be null
dave
@pulse: tried all of the above nope it does not workgenerally I use $("#c_album").val('');
dave
A: 
$(function(){
    $('#mybutton').click(function(e){
        $('input#c_album').val('hello');
    });
});

Is a general method which should work. Without knowing more of your code it's hard to be more specific.

Chris
+1  A: 
    $(function(){
       $('#btnSubmit').bind('click', function(){
           $('input#c_album').val('hello');
// OR
           $('#c_album').val('hello');
// OR
           $('input[id=c_album]').val('hello');
       });
   });
Devi
A: 

it worked, the error was, there was no id for the textbox

<input type='text' name='text' id='text'>

Thanks all of you..

dave
A: 
$('#submit').bind('click',(function(){
        $('#src_box').val('hello');
    });

There is a problem in this code, so try this -

$('#submit').bind('click',function(){
        $('#src_box').val('hello');
    });

The problem is you have used a '(' before the function(). But now it will work fine :)

Devi