HTML Click "Works in IE" not "FireFox", Chrome
It should be something simple: I created a frame page with two possible sources for the target frame based on a two-choice form. I used the OnClick event to catch the user to show the corresponding page. It works great in Internet Explorer 7, replacing the two original pages. FireFox 3 and Chrome only show the default source.
HEAD Script section:
function SwapInlineFrameSource()
{
var rsRadio, rsiFrame;
rsRadio=document.getElementById('County');
rsiFrame=document.getElementById('RatesFrame')
if (rsRadio.checked===true) {
rsiFrame.src="SantaCruzRates.htm";
}
else {
rsiFrame.src="DelNorteRates.htm";
}
}
BODY form section (commented out to appear here):
<input type="radio" value="SC" checked name="County" onclick="SwapInlineFrameSource()">
Santa Cruz
<input type="radio" value="DN" name="County" onclick="SwapInlineFrameSource()" >
Del Norte
What am I missing? (Live example: http://www.raintrees.com/rates.html )
Thank!
MR
You are using getElementByID, but you are not specifying IDs for your inputs. Maybe think about this:
function SwapInlineFrameSource(rdoButton)
{
rsiFrame = document.getElementById("RatesFrame");
rsiFrame.src = rdoButton.value;
}
<input type="radio" value="SantaCruzRates.htm" checked="checked" name="County" onClick="SwapInlineFrameSource(this);">Santa Cruz</input>
<input type="radio" value="DelNorteRates.htm" name="County" onClick="SwapInlineFrameSource(this);">Del Norte</input>
Your code is wrong ....
var rsRadio, rsiFrame;
rsRadio=document.getElementById('County');
rsiFrame=document.getElementById('RatesFrame')
if (rsRadio.checked===true) {
I'm assuming you mean getElementsByName and not ID, because you don't have a county ID on these radio buttons.
You actually need to determine which radio button is set so that you can do something like (assuming there are only two options)
if(document.getElementsByName()[0].checked){
// show Santa Cruz Rates
}else{
// show other rates
}
I don't believe getElementById works with frames in firefox. I've always used ["frameID"] frames, which seem to work more consistently.