views:

33

answers:

3

Hey guys,

Quick question... I was wondering how I can get this to happen.

Okay I have an input field like such:

<input type="text" id="input1" size="10" name="" value="" class="checked other_amount" onfocus="Toggle('radio1', 'input1');" />

I would like to click on a div with an ID of #resetPrompt and fill the empty name attr from the input with "other_amount"

I'm out of ideas its been a long day

Thanks guys,

Matt

+3  A: 
$('#resetPrompt').click(function(){
    $('#input1').attr('name', 'other_amount');
});
Alex
A: 

If "other_amount" is the ID of the other input, use attr and val as follows:

$("#resetPrompt").click(function(){
    var otherValue = $("#other_amount").val();
    $("#input1").attr("name", "someName");
}
Raul Agrait
These all work man thanks!
Matthew
A: 

Assuming that "other_amount" is the name, not id of the corresponding input.

$('#resetPrompt').click( function() {
   $('#input1').attr('name', $('[name=other_amount]').val());
});
tvanfosson
These all work man thanks!
Matthew