Link to home
Start Free TrialLog in
Avatar of mattturley
mattturley

asked on

JavaScript to change Frame Source using HTML Form Select values

I am trying to change the source of the current frame using a Form Select value and the onclick of a button.  For instance, my select and button would look like this.

<form name="form1">
                    <select name="menu1">
                      <option value="#">Menu</option>
                      <option value="L1T1_01.htm">Objectives</option>
                      <option value="L2T1_01.htm">Introduction</option>
                      <option value="L3T1_01.htm">Overview of Constitutional History</option>
                      <option value="L4T1_01.htm">Bill of Rights</option>
                      <option value="L5T1_01.htm">What the Constitution Means to You</option>
                      <option value="L6T1_01.htm">Summary </option>
                    </select>
                    <input type="button" name="Button1" value="Go" onClick="MM_jumpMenuGo()">
                  </form>

From here, I have thought of many ways to write the MM_jumpMenuGo function, but none have worked.

Any thoughts?

Your help would be greatly appreciated!

Matt
Avatar of bebonham
bebonham

<script>
function frame_src(url)
{
document.getElementById("frame_ele").src=url;
}
</script>


<form name="form1">
                    <select name="menu1" onchange="frame_src(this.value)">
                      <option value="#">Menu</option>
                      <option value="http://www.google.com">Objectives</option>
                      <option value="L2T1_01.htm">Introduction</option>
                      <option value="L3T1_01.htm">Overview of Constitutional History</option>
                      <option value="L4T1_01.htm">Bill of Rights</option>
                      <option value="L5T1_01.htm">What the Constitution Means to You</option>
                      <option value="L6T1_01.htm">Summary </option>
                    </select>
                    <input type="button" name="Button1" value="Go" onClick="MM_jumpMenuGo()">
                  </form>
<iframe id=frame_ele src="" width=500 height=500></iframe>
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mattturley

ASKER

Many thanks!!  This worked like a charm without having to change my frameset.