View Full Version : parsing radio selections in textarea box

10-07-2009, 09:47 PM

I need some help! I have some code that has a comments box and 2 radio buttons that ask if you want to be contacted about your comments. If you select "Yes", you get another set of radio buttons that ask you to choose a method of contact. When you choose a method, that selected methods value is parsed to the top of the textarea field, placing the comment below. I pretty much have it working, however, if I enter a comment in the "Comments" field, select "Yes", then select "email" and change to "Phone Morning", it concatnates the values in the textarea box instead of replacing the contact method value while still retaining the comment entered below.

Also, if at all possible, I wanted to clear only the contact method value out of the textarea field and leave only the comment when you go back and click the "No" radio button.

Can anyone please help?

Thanks in advance!

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type='text/javascript'>

function showContactType(obj){
if(document.storeCodeFeedbackForm.contact[1].checked == true){
document.getElementById("contactType").style.display = 'inline';
}else if(document.storeCodeFeedbackForm.contact[0].checked == true){
document.storeCodeFeedbackForm.contactType[i].checked = false;
document.getElementById("contactType").style.display = 'none';
function printContactType(src)
document.storeCodeFeedbackForm.customerMessage.value = src.value + "\n" + "------------------------" + "\n\n" + document.storeCodeFeedbackForm.customerMessage.value;
<form name="storeCodeFeedbackForm">
<td>Comments:<br />
<textarea id='textArea' name="customerMessage" cols="30" rows="10"></textarea>
<br />
<td> Would you like to be contacted about your comments? <span style="color:#990000; font-weight:normal">*</span>
<input type="radio" name="contact" value="no" onclick="showContactType(this);disableField(this);">
<input type="radio" name="contact" value="yes" onclick="showContactType(this)">
Yes </td>
<td><table cellpadding="0" cellspacing="0" border="0" width="100%" id="contactType" style="display:none">
<td class="tir" style="border-top:1px dashed #cccccc; padding-top:5px;">(Choose One)<span style="color:#990000">*</span>
<input type="radio" name="contactType" value="Contact me by: e-Mail" onClick='printContactType(this);'>
<input type="radio" name="contactType" value="Contact me by: phone in the morning" onClick='printContactType(this);'>
Phone Morning
<input type="radio" name="contactType" value="Contact me by: phone in the afternoon" onClick='printContactType(this);'>
Phone Afternoon
<input type="radio" name="contactType" value="Contact me by: phone in the evening" onClick='printContactType(this);'>
Phone Evening</td>