Jump to content

function to change input text name


davocold

Recommended Posts

 

thanks, i think am getting somewhere but what am i doing wrong with the following functions

 

<?php

function english()

  {

  $('#pfc_words').attr('name', 'english');

}

function saisie()

  {

  $('#pfc_words').attr('name', 'saisie');

}

?>

You can just use the following

document.getElementById('pfc_words').name = 'MY_NEW_NAME';

you don't need jquery or anything else

 

thanks, i want the change when a radio button is selected, i mean when i select a radio button i want the name of the pfc_words change to "english". How do i go about doing that?

 

can i use

onClick="document.getElementById('pfc_words').name = 'MY_NEW_NAME';"

in radio button?

Yes, your onclick will work. If you want to make a function, you can do the following

<input type="radio" onclick="my_name_change_func('english');" ....
... later in your script...
function my_name_change_func(nm){
    document.getElementById('pfc_words').name = nm;
}

Yes, your onclick will work. If you want to make a function, you can do the following

<input type="radio" onclick="my_name_change_func('english');" ....
... later in your script...
function my_name_change_func(nm){
    document.getElementById('pfc_words').name = nm;
}

 

thanks alot, i used the onclick and it changes the name but only once, if i click another radio button to change it back to the previous name, it doesn't.  would the function way of doing this fix it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.