orangecuse
IS-IT--Management
Hello, I would like to introduce myself by asking a question. It has been a while since I have done any programming until just recently. Here is my situation...
I am working on some code where I ask the user to enter their age into a text box. The next question asks whether they are male or female(radio button style). Now the key is that when the user clicks 'Male' or 'Female' their selection will be entered into the text box, following their Age they entered. Now my problem is, say I enter the age 23 and click on Male. The text box will output "23, Male". Now that is perfectly fine, but when I change my selection from Male to Female, the text you will see is "23, Male, Female" instead of just "23, Female"
I can't seem to get rid of this problem.
Hopefully that made sense. If you don't understand, you can copy my code and go to and enter the data to see for yourself.
Here is my code:
<form name="description">
Age:
<input id="text" name="text" type="text" >
<br><br><br>
Male:
<input type="radio" name="Sex" value=", male"
onclick="(text.value=text.value+this.value)">
<br>
Female:
<input type="radio" name="Sex" value=", female"
onclick="(text.value=text.value+this.value)">
</form>
Thanks in advance.
I am working on some code where I ask the user to enter their age into a text box. The next question asks whether they are male or female(radio button style). Now the key is that when the user clicks 'Male' or 'Female' their selection will be entered into the text box, following their Age they entered. Now my problem is, say I enter the age 23 and click on Male. The text box will output "23, Male". Now that is perfectly fine, but when I change my selection from Male to Female, the text you will see is "23, Male, Female" instead of just "23, Female"
I can't seem to get rid of this problem.
Hopefully that made sense. If you don't understand, you can copy my code and go to and enter the data to see for yourself.
Here is my code:
<form name="description">
Age:
<input id="text" name="text" type="text" >
<br><br><br>
Male:
<input type="radio" name="Sex" value=", male"
onclick="(text.value=text.value+this.value)">
<br>
Female:
<input type="radio" name="Sex" value=", female"
onclick="(text.value=text.value+this.value)">
</form>
Thanks in advance.