Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button and Textbox 1

Status
Not open for further replies.

BrendaD

Programmer
Jan 26, 2001
25
CA
I am stuck!

I want to populate a textbox with the content of another textbox based on whether a radio button has been clicked.

Here is the javescript code:

function setValue() {
if (document.frmOcc.rbFirstContact[1].checked) {
document.frmOcc.txtArriveEvent.value=document.frmOcc.txtOffReportArrive.value;
return true;

}

else if (document.frmOcc.rbFirstContact[0].checked) {
alert("Did you attend the Event?")
document.frmOcc.txtArriveEvent.focus();
return true;

}
}

Here is how I am calling it:

<label>
<input type="radio" name="rbFirstContact" onClick="setValue(this.form)" value="Phone">
Phone</label>
(if phone, did Officer go to Event?) <br>
<label>
<input type="radio" name="rbFirstContact" onClick="setValue(this.form)" value="Seen">
Seen</label>
(if seen, populate Arrived at Event) <br>


Can anyone see what I am doing wrong?

Thanks!
 
make sure your text boxes lie between your opening and closing form tags.

next, i would try changing your function to this:

Code:
function setValue(f) {
    if (f.elements['rbFirstContact'][1].checked) {
        f.elements['txtArriveEvent'].value=f.elements['txtOffReportArrive'].value;
    } else if (f.elements['rbFirstContact'][1].checked) {
        alert("Did you attend the Event?")
        f.elements['txtArriveEvent'].focus();        
    }
}



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top