Jump to content

function to change input text name


davocold

Recommended Posts

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?

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.