/    Sign up×
Community /Pin to ProfileBookmark

using box or list

Ok, here’s the original script:

<form name=”jumpy”>
[COLOR=DarkRed]<select name=”example” size=”1″ onChange=”gone()”>
<!– CHANGE THE BELOW URLS TO YOUR OWN–>
<option value=”http://www.yahoo.com” selected>Yahoo.com</option>
<option value=”http://www.google.com”>Google</option>
<option value=”http://www.lycos.com”>Lycos</option>
<option value=”http://www.AltaVista.com”>AltaVista</option>
</select>

<input type=”button” name=”test” value=”Go!” onClick=”gone()”>
</form>[/COLOR]
<script language=”javascript”>
<!–

//Specify display mode (0 or 1)
//0 causes document to be displayed in an inline frame, while 1 in a new browser window
var displaymode=1
//if displaymode=0, configure inline frame attributes (ie: dimensions, intial document shown
var iframecode='<iframe id=”external” style=”width:95%;height:400px” src=”http://www.yahoo.com”></iframe>’

/////NO NEED TO EDIT BELOW HERE////////////

if (displaymode==0)
document.write(iframecode)

function gone(){
var selectedurl=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
if (document.getElementById&&displaymode==0)
document.getElementById(“external”).src=selectedurl
else if (document.all&&displaymode==0)
document.all.external.src=selectedurl
else{
if (!window.win2||win2.closed)
win2=window.open(selectedurl)
//else if win2 already exists
else{
win2.location=selectedurl
win2.focus()
}
}
}
//–>
</script>

[COLOR=DarkOliveGreen]the red part is where I editied to this;[/COLOR]

<html>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>Jumpy</title>

<SCRIPT>
function yes() {
MMDiv.style.visibility=’visible’;
mainform.MakeModel.focus();
}
function no() {
MMDiv.style.visibility=’hidden’;
}
</SCRIPT>

</head>

<body>

<form name=”jumpy”>

<INPUT TYPE=”RADIO” NAME=”PRINTER” onclick=”no();” CHECKED>Listed

[COLOR=DarkRed]<select name=”example” size=”1″ onChange=”gone()” onclick=”no();”>
<!– CHANGE THE BELOW URLS TO YOUR OWN–>
<option value=”http://www.yahoo.com” selected>Yahoo.com</option>
<option value=”http://www.google.com”>Google</option>
<option value=”http://www.lycos.com”>Lycos</option>
<option value=”http://www.AltaVista.com”>AltaVista</option>
<BR><BR>
<INPUT TYPE=”RADIO” NAME=”PRINTER” onclick=”yes();”>Other

<BR>
<DIV ID=”MMDiv” style=”visibility:hidden”>
<LABEL FOR=”MakeModel”>
<INPUT TYPE=”TEXT” name=”example” ID=”MakeModel”>
Or, Enter your own using format http://www.mysite.com</LABEL>
</DIV>
<BR>

</select>
</form>[/COLOR]<input type=”button” name=”test” value=”Go!” onClick=”gone()”>
<BR>
<BR>

<script language=”javascript”>
<!–

//Specify display mode (0 or 1)
//0 causes document to be displayed in an inline frame, while 1 in a new browser window
var displaymode=0
//if displaymode=0, configure inline frame attributes (ie: dimensions, intial document shown
var iframecode='<iframe id=”external” style=”width:95%;height:400px” src=”http://www.yahoo.com”></iframe>’

/////NO NEED TO EDIT BELOW HERE////////////

if (displaymode==0)
document.write(iframecode)

function gone(){
var selectedurl=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
if (document.getElementById&&displaymode==0)
document.getElementById(“external”).src=selectedurl
else if (document.all&&displaymode==0)
document.all.external.src=selectedurl
else{
if (!window.win2||win2.closed)
win2=window.open(selectedurl)
//else if win2 already exists
else{
win2.location=selectedurl
win2.focus()
}
}
}
//–>
</script>

</body>

</html>

[COLOR=DarkOliveGreen]Just in case you cant tell what I’m trying to do, here’s what it is. I’m trying to get it to where you can either select something from the list to show or you can type in what you want and it will show that. I’m not sure if I’m even on the right track and I dont know what to search for to figure it out my self. Can any one help? ? [/COLOR]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@BaptistKittyauthorSep 26.2005 — bump

no help?
Copy linkTweet thisAlerts:
@BaptistKittyauthorSep 27.2005 — Final Bump....

Nothing?
Copy linkTweet thisAlerts:
@NedalsSep 27.2005 — It was easier to rewrite than point out all the errors, but please, please read through this revised code and understand how it works. Ask if you don't understand.

One major change I made was to move most of the javascript into the <head>. This make it much easier to read. The only javscript left in the html flow was the document.write statement.

I also took out the popup window option and any code associated with providing the option.

<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
&lt;title&gt;Jumpy&lt;/title&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
var iframecode='&lt;iframe id="external" style="width:95%;height:400px" src="http://www.yahoo.com"&gt;&lt;/iframe&gt;'

function yes() {
MMDiv.style.visibility='visible';
document.getElementById('MakeModel').focus();
}

function no() {
MMDiv.style.visibility='hidden';
}

function gone(URL){
if (!URL) { URL = document.getElementById("MakeModel").value; }
if (!URL) { return false; }
document.getElementById("external").src = "http://" + URL
}
//--&gt;
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form name="jumpy"&gt;
&lt;INPUT TYPE="RADIO" NAME="PRINTER" onclick="no();" CHECKED&gt;Listed

&lt;select name="example" onChange="gone(this.value)" onclick="no();"&gt;
&lt;option value="www.yahoo.com" selected&gt;Yahoo.com&lt;/option&gt;
&lt;option value="www.google.com"&gt;Google&lt;/option&gt;
&lt;option value="www.lycos.com"&gt;Lycos&lt;/option&gt;
&lt;option value="www.AltaVista.com"&gt;AltaVista&lt;/option&gt;
&lt;/select&gt;
&lt;INPUT TYPE="RADIO" NAME="PRINTER" onclick="yes();"&gt;Other
&lt;BR&gt;

&lt;DIV ID="MMDiv" style="visibility:hidden"&gt;
&lt;LABEL FOR="MakeModel"&gt;
&lt;INPUT TYPE="TEXT" name="example" ID="MakeModel"&gt; Or, Enter your own using format www.mysite.com
&lt;/LABEL&gt;
&lt;/DIV&gt;
&lt;BR&gt;
&lt;input type="button" name="test" value="Go!" onclick="gone()"&gt;
&lt;/form&gt;
&lt;BR&gt;
&lt;BR&gt;
&lt;script type="text/javascript"&gt;document.write(iframecode)&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@BaptistKittyauthorSep 28.2005 — Ok, It works great now thank you!

Also, sorry I didnt reply sooner, I was trying it out and never got back on here yeasterday. (I got distracted by something else I figured out how to do sorry :o ) You said to say if I didnt understand it so here I am. I dont know but some basics in javascripting (I can edit some things and most every thing I've learned has been by trial and error) and my dad only know some php but no js. I dont understand what you did or why it works.... Are there any good pages or anything where I can read up on it or something? or any other suggestions? Thanks for all your help though!!!
Copy linkTweet thisAlerts:
@NedalsSep 28.2005 — Where to begin?

I'll assume you know HTML and that you understand what variables, used in programming, are.

In the HTML.

This line simply creates the iframe as defined by 'iframecode'
&lt;script type="text/javascript"&gt;document.write(iframecode)&lt;/script&gt;

This line calls the javascript function 'gone()' whenever the select is changed (onchange event).

'this.value' gets the currently selected option which is parsed to the 'gone()' function.

In addition, the 'onclick' event calls the 'no()' function.
&lt;select name="example" onChange="gone(this.value)" onclick="no();"&gt;

Let look at the 'gone()' function.
<i>
</i>function gone(URL){
// URL is the value parsed by 'this.value', the selected &lt;option value="www.domain.com"&gt;
// If there is no URL (!URL), then the function was called when you clicked on the 'go' button here
// &lt;input type="button" name="test" value="Go!" onclick="gone()"&gt;
// so get the URL from the 'MakeModel' &lt;input&gt;
if (!URL) { URL = document.getElementById("MakeModel").value; }

// If there is still no URL, then nothing was entered, so exit the function, 'return false'
if (!URL) { return false; }

// If there is a URL, change the .src of the iframe and display the page
document.getElementById("external").src = "http://" + URL
}

The other two functions are pretty self explanitory.

I moved all the javascript into the <head> section simply because it's MUCH easier to read. It is definately a habit all espiring web page designers should adopt.

You may want to visit this site for some tutorials on Javascript

http://www.w3schools.com/

Hope that helps. ?
×

Success!

Help @BaptistKitty 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 5.6,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...