clearing certain fields in a form

wxdqz

New Member
I've already got a form programmed as follows

(o) radio valueA
[text fieldA1*] [menu listA1*] {*validation coded, both must be entered if radio valueA is checked}
[text fieldA2] [menu listA2] {no validation code, optional entry}

(o) radio valueB
[text fieldB1*] [menu listB1*] {*validation coded, both must be entered if radio valueB is checked}
[text fieldB2] [menu listB2] {no validation code, optional entry}

(o) radio valueC

What I also have programmed in is when the user clicks Radio ValueA anything already entered in the text/menu fields in 'B' is cleared...and visa versa. And if the user clicks C, everything in the 'A' and 'B' groups are cleared.

With the following sample Javascript code:

function process(obj){
if(obj.value=="r1"){
document.form1.t3.value = "";
document.form1.t4.value = "";
}else if(obj.value=="r2"){
document.form1.t1.value = "";
document.form1.t2.value = "";
}

<input type="Radio" name="r1" value=http://www.webdeveloper.com/forum/archive/index.php/"r1" onclick="process(this);"></input><br>
<input type="Text" name="t1"></input><br>
<input type="Text" name="t2"></input><br>
<input type="Radio" name="r1" value="r2" onclick="process(this);"></input><br>
<input type="Text" name="t3"></input><br>
<input type="Text" name="t4"></input><br>

HOWEVER...I need to take this one step further. I have found in testing - that if the user clicks radio valueB, THEN enters something text/menu areas for'A', the 'A' areas do not get cleared out.

I have tried attaching the JS with onChange, onFocus and onBlur on these form fields - but nothing is working. I've even tried to attach to JS to the form tag - no go.

I don't know what the chances are that the use will do this reverse sort of thing - but I am trying to cover all my bases.

Thanks in advance!

~MVA
 
Back
Top