Click to See Complete Forum and Search --> : Can I use radio button to insert text into text field?


wvmlt
11-27-2004, 07:00 AM
I have a text field on my site

<input type=text name=useravatar value=\"$useravatar\">


where users can insert the url of an avatar. I would like to present the user a group of avatars to choose from and when one is selected, have the url entered in the text field. Can I do this or do I need to just enter the url next to the avatar and tell users to paste the url of the avatar they want to use?

GeorgeJohnson
11-27-2004, 10:48 AM
You would use JavaScript and it go something like the following:

<script language=javascript>

function changeField(rName) {
eval("document.formName.useravatar.value = document.formName." + rName + ".value");
}

</script>


For the radio button:

<input type=radio name=serveravatar1 value="addressOfServerAvatar" onClick="changeField('serveravatar1');">

Course you could do the changes inside each radio button, and if I am not mistaken, in JavaScript, if your change "changeField('serveravatar1');" to "changeField('this.Field');" will reference the current field calling the function. But don't quote me on that cause my memory is fuzzy in that area right now...