/    Sign up×
Community /Pin to ProfileBookmark

Forms, Links, and Iframes

I just spent over and hour trying to figure this out and I’m forced to post here rather than spend more time trying to do forum searches for this specific little thing.

I want to create a drop down menu with a ‘go’ button. I can find the code for that easy enough through search engines.

But every place I went had code that simply opened up the new link either on that page or in a new page.

I have an iframe on my page with NAME=”data” and I want my “go” button, when pressed, to open the link associated with the option selected from the menu INTO the “data” iframe.

I know this is possible and I’m probably just too tired to figured it out on my own right now. Can someone help me please?

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 05.2004 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Load Iframe</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--
function LoadIframe() {
var obj=document.getElementById('select1');
document.getElementById('iframe1').src=obj.options[obj.selectedIndex].value;
}
//-->
</script>

<style type="text/css">
&lt;!-- <br/>
--&gt;
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="default.html" method="post" id="form1" onsubmit="LoadIframe(); return false;"&gt;
&lt;p&gt;
&lt;select id="select1"&gt;
&lt;option value="page1.html"&gt;page1&lt;/option&gt;
&lt;option value="page2.html"&gt;page2&lt;/option&gt;
&lt;option value="page3.html"&gt;page3&lt;/option&gt;
&lt;/select&gt;
&lt;button type="submit"&gt;submit&lt;/button&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;iframe src="default.html" id="iframe1"&gt;&lt;/iframe&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @BJC spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...