如何在文本区域输入文本对应特定的单选按钮?

时间:2023-01-15 21:16:05

my fellow developers!

我的开发人员!

So...I have made a form with radio buttons. What I'm interested in building is to have next to each group of radio buttons, one textarea, so as to give the user the option to input his choice either by selecting the radio button or by entering the corresponding value in the textarea.

所以......我用单选按钮制作了一个表单。我对构建感兴趣的是在每组单选按钮旁边,一个文本区域,以便通过选择单选按钮或在textarea中输入相应的值,让用户可以选择输入他的选择。

And also, I'd like to make the value of the selected radio button, appear in the textarea.

而且,我想让所选单选按钮的值出现在textarea中。

Is there a way to link the two of them?

有没有办法将他们两个联系起来?

My example-markup is:

我的示例标记是:

 <label>Nationality:</label> <br>
 <input type="radio" name="nationality" value="null">
 <input type="radio" name="nationality" value="greek">Greece
 <input type="radio" name="nationality" value="italian">Italy
 <input type="radio" name="nationality" value="german">Germany
 <input type="radio" name="nationality" value="russian">Russia

2 个解决方案

#1


-1  

You would be able to use Javascript (I would recommend Jquery, a collection of classes designed to make Javascript simpler), to do what you are asking.

你可以使用Javascript(我会推荐Jquery,一个旨在使Javascript更简单的类的集合)来做你想要的。

#2


-1  

You should use javascript to make the value of the radio appear in your textarea

您应该使用javascript使收音机的值显示在您的textarea中

For your question about the choice, not sure if i understood, but it's on php side i think

关于选择的问题,不确定我是否理解,但我认为这是在php方面

If the user choose radio No need for textarea

如果用户选择无线电不需要textarea

If the user choose textarea no need for radio

如果用户选择textarea则不需要收音机

But i think you should also link each radio item with his textarea, so in php, you know which radio corresponds to which textarea,and thus make a test to be sure the visitor entered the correct textarea

但我认为你还应该将每个广播项目与他的textarea链接起来,所以在php中,你知道哪个广播对应哪个textarea,从而进行测试以确保访问者进入正确的textarea

#1


-1  

You would be able to use Javascript (I would recommend Jquery, a collection of classes designed to make Javascript simpler), to do what you are asking.

你可以使用Javascript(我会推荐Jquery,一个旨在使Javascript更简单的类的集合)来做你想要的。

#2


-1  

You should use javascript to make the value of the radio appear in your textarea

您应该使用javascript使收音机的值显示在您的textarea中

For your question about the choice, not sure if i understood, but it's on php side i think

关于选择的问题,不确定我是否理解,但我认为这是在php方面

If the user choose radio No need for textarea

如果用户选择无线电不需要textarea

If the user choose textarea no need for radio

如果用户选择textarea则不需要收音机

But i think you should also link each radio item with his textarea, so in php, you know which radio corresponds to which textarea,and thus make a test to be sure the visitor entered the correct textarea

但我认为你还应该将每个广播项目与他的textarea链接起来,所以在php中,你知道哪个广播对应哪个textarea,从而进行测试以确保访问者进入正确的textarea