PDA

View Full Version : Kinda like combining or duplicating a script



peter
Jun 29th, 2002, 07:27 AM
Hi

I found this script and would like to use it twice on the same page. meaning two instances of it.
one on the left where it is now, and the other on the right...
ie two FLOATING MENUS

Can anyone please help. The site is
http://javascriptkit.com/script/script2/alwayscombo.shtml

<span id="staticcombo" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy">
<p><select name="example" size="1" onChange="gone()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}
//-->
</script>

<input type="button" name="test" value="Go!"
onClick="gone()">
</p>
</form>
</span>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize(){
if (document.all){
combowidth=staticcombo.offsetWidth
comboheight=staticcombo.offsetHeight
setInterval("staticit_ie()",50)
staticcombo.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo.document.width
comboheight=document.staticcombo.document.height
setInterval("staticit_ns()",50)
document.staticcombo.visibility="show"
}
}

function staticit_ie(){
staticcombo.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-30
staticcombo.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns(){
document.staticcombo.left=pageXOffset+window.innerWidth-combowidth-30
document.staticcombo.top=pageYOffset+window.innerHeight-comboheight
}

window.onload=initialize
</script>

thanks
peter

ACJavascript
Jun 29th, 2002, 03:15 PM
Here ya go this should work;)

-----------

<html>
<head>
<title>Double Combo</title>
<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}
//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize(){
if (document.all){
combowidth=staticcombo.offsetWidth
comboheight=staticcombo.offsetHeight
setInterval("staticit_ie()",50)
staticcombo.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo.document.width
comboheight=document.staticcombo.document.height
setInterval("staticit_ns()",50)
document.staticcombo.visibility="show"
}
}

function staticit_ie(){
staticcombo.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-30
staticcombo.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns(){
document.staticcombo.left=pageXOffset+window.innerWidth-combowidth-30
document.staticcombo.top=pageYOffset+window.innerHeight-comboheight
}

</script>


<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy2.example2.options[document.jumpy2.example2.selectedIndex].value
}
//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize2(){
if (document.all){
combowidth=staticcombo2.offsetWidth
comboheight=staticcombo2.offsetHeight
setInterval("staticit_ie2()",50)
staticcombo2.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo2.document.width
comboheight=document.staticcombo2.document.height
setInterval("staticit_ns2()",50)
document.staticcombo2.visibility="show"
}
}

function staticit_ie2(){
staticcombo2.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-610
staticcombo2.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns2(){
document.staticcombo2.left=pageXOffset+window.innerWidth-combowidth-610
document.staticcombo2.top=pageYOffset+window.innerHeight-comboheight
}
</script>

</head>
<body onload="initialize() + initialize2()">

<span id="staticcombo" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy">
<p><select name="example" size="1" onChange="gone()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test" value="Go!"
onClick="gone()">
</p>
</form>
</span>

<span id="staticcombo2" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy2">
<p><select name="example2" size="1" onChange="gone()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test2" value="Go!"
onClick="gone()">
</p>
</form>
</span>

</body>
</html>

------------


Hope it works for ya:D:D:D

peter
Jun 30th, 2002, 06:10 AM
Much thanks ACjavascript

Great, Very Great works like a peach...perfectamundo...

Very much appreciated

peter
Jul 1st, 2002, 02:25 PM
Hi again
AC are you still around...can you fix this, or shed some light on it?

Both scripts have different links....
However both scripts go to the same URLS/links even though the URLs descriptions differ..... I double checked to see if I screwed up somewhere...but I cannot find any ...

Does anyone have any idea what I could have done to cause this.

Thanks

ACJavascript
Jul 1st, 2002, 04:54 PM
Yea i'm here. hehe

The Problem is that both selects were calling the same function ( gone() )

So what i did is i created a second gone2() function for the second select.

Its here in the code boldfaced

-------------------

<html>
<head>
<title>Double Combo</title>
<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}

//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize(){
if (document.all){
combowidth=staticcombo.offsetWidth
comboheight=staticcombo.offsetHeight
setInterval("staticit_ie()",50)
staticcombo.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo.document.width
comboheight=document.staticcombo.document.height
setInterval("staticit_ns()",50)
document.staticcombo.visibility="show"
}
}

function staticit_ie(){
staticcombo.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-30
staticcombo.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns(){
document.staticcombo.left=pageXOffset+window.innerWidth-combowidth-30
document.staticcombo.top=pageYOffset+window.innerHeight-comboheight
}

</script>


<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone2()
{
location=document.jumpy2.example2.options[document.jumpy2.example2.selectedIndex].value
}
//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize2(){
if (document.all){
combowidth=staticcombo2.offsetWidth
comboheight=staticcombo2.offsetHeight
setInterval("staticit_ie2()",50)
staticcombo2.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo2.document.width
comboheight=document.staticcombo2.document.height
setInterval("staticit_ns2()",50)
document.staticcombo2.visibility="show"
}
}

function staticit_ie2(){
staticcombo2.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-610
staticcombo2.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns2(){
document.staticcombo2.left=pageXOffset+window.innerWidth-combowidth-610
document.staticcombo2.top=pageYOffset+window.innerHeight-comboheight
}
</script>

</head>
<body onload="initialize() + initialize2()">

<span id="staticcombo" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy">
<p><select name="example" size="1" onChange="gone()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test" value="Go!"
onClick="gone()">
</p>
</form>
</span>

<span id="staticcombo2" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy2">
<p><select name="example2" size="1" onChange="gone2()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test2" value="Go!"
onClick="gone2()">
</p>
</form>
</span>

</body>
</html>


-------------

HappyScripting:D:D

peter
Jul 2nd, 2002, 09:41 AM
Very logical and simple when you think about it ain't it....?
I can kick myself for not at least trying to figure that out...
After the effort you put in, in changing the duplications to make them unique...
Oh well I am new, I hope to catch on

Thanks, very much...

ACJavascript
Jul 2nd, 2002, 09:26 PM
Dont kick yourself. Everyone learns something new everyday. Whether it be javascript or a good ol lesson about life. If you look at this forum you can see my name popup like 10 times asking for some help. Good Luck ;)

peter
Jul 3rd, 2002, 01:02 AM
Hi A*C

On your recommendation, I have not kicked myself....:D Thanks for the support...

With your permission I am going to "lean" on your skills just a little more...

I figured the site would be complete if I had a third floating menu in it...

I now understand the script logic...

How would I place third floating menu in the script....?

Thanks:)

ACJavascript
Jul 3rd, 2002, 02:10 AM
Sure no problem;)

-----------

<html>
<head>
<title>Double Combo</title>
<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}

//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize(){
if (document.all){
combowidth=staticcombo.offsetWidth
comboheight=staticcombo.offsetHeight
setInterval("staticit_ie()",50)
staticcombo.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo.document.width
comboheight=document.staticcombo.document.height
setInterval("staticit_ns()",50)
document.staticcombo.visibility="show"
}
}

function staticit_ie(){
staticcombo.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-30
staticcombo.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns(){
document.staticcombo.left=pageXOffset+window.innerWidth-combowidth-30
document.staticcombo.top=pageYOffset+window.innerHeight-comboheight
}

</script>
<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone3()
{
location=document.jumpy3.example3.options[document.jumpy3.example3.selectedIndex].value
}

//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize3(){
if (document.all){
combowidth=staticcombo3.offsetWidth
comboheight=staticcombo3.offsetHeight
setInterval("staticit_ie3()",50)
staticcombo3.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo3.document.width
comboheight=document.staticcombo3.document.height
setInterval("staticit_ns3()",50)
document.staticcombo3.visibility="show"
}
}

function staticit_ie3(){
staticcombo3.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-320
staticcombo3.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns3(){
document.staticcombo3.left=pageXOffset+window.innerWidth-combowidth-320
document.staticcombo3.top=pageYOffset+window.innerHeight-comboheight
}

</script>

<script language="javascript">
<!--

/*Always-visible combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 400+ free JavaScripts here!
*/

function gone2()
{
location=document.jumpy2.example2.options[document.jumpy2.example2.selectedIndex].value
}
//-->
</script>


<script language="JavaScript1.2">
var combowidth=''
var comboheight=''

function initialize2(){
if (document.all){
combowidth=staticcombo2.offsetWidth
comboheight=staticcombo2.offsetHeight
setInterval("staticit_ie2()",50)
staticcombo2.style.visibility="visible"
}
else if (document.layers){
combowidth=document.staticcombo2.document.width
comboheight=document.staticcombo2.document.height
setInterval("staticit_ns2()",50)
document.staticcombo2.visibility="show"
}
}

function staticit_ie2(){
staticcombo2.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-610
staticcombo2.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight
}

function staticit_ns2(){
document.staticcombo2.left=pageXOffset+window.innerWidth-combowidth-610
document.staticcombo2.top=pageYOffset+window.innerHeight-comboheight
}
</script>

</head>
<body onload="initialize() + initialize2() + initialize3()">

<span id="staticcombo" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy">
<p><select name="example" size="1" onChange="gone()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test" value="Go!"
onClick="gone()">
</p>
</form>
</span>

<span id="staticcombo2" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy2">
<p><select name="example2" size="1" onChange="gone2()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test2" value="Go!"
onClick="gone2()">
</p>
</form>
</span>

<span id="staticcombo3" style="position:absolute;left:0;top:0;visibility:hidden">
<form name="jumpy3">
<p><select name="example3" size="1" onChange="gone3()">
<option value="http://www.codearena.com">CodeArena.com</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.geocities.com">Geocities</option>
<option value="http://www.cnn.com">CNN</option>
</select>

<input type="button" name="test3" value="Go!"
onClick="gone2()">
</p>
</form>
</span>
</body>
</html>

------------


HappyScripting:D:D:D:D

peter
Jul 3rd, 2002, 03:06 AM
Resolved

I have followed your logic and have adapted my first script as a newbie...I feel great...not a major thing in the life of you great scripters, but a major, major, major, hurdle for me...it means I kinda know what is happening and where it is happening in the script...

I notice you have provided the solution in your usual helpful way...
Thanks...
Can I add colour to the background...I want colour code the menus, right now they blend in on the page(not such a bad idea) but I may use the option for colour...

1. I have permission to link to information on another site.
2. I would like to show the information/content as it is.
3. When the link is clicked (in a floating menu)
///4. I wish for the pages to be shown BUT WITHIN my pages with the information that I want to show...///

How is that possible...
This is the site...that I wish to link to:
http://www.albaraka.com/english/resource/Fatwa/index.html />
as well as this one:
http://www.itpapers.com/ />
Can you help in this....

ACJavascript
Jul 3rd, 2002, 04:31 AM
Sure no problem.

1) Color the menus

http://www.acjavascripts.com/Mouse_Over_Scripts.html

Go there and look at the Select BgChanger & Select BgFader.
There both mine so your free to use them:)

If you don't want that then just put this right before the ending of the select tag

style="background-color:black;color:lime;">

the full code

<select name="whatever" onchange="whatever" style="background-color:black;color:lime;">

2)Linking

Well you could acomplish what you want by useing frames. The bottom frame has your selects, and the main frame(the rest of the window) can show the links. Something like that, what do you think?



;):);)

peter
Jul 3rd, 2002, 07:11 AM
Hmmmm...

I guess...though I am kinda running from the technicality of imposing frames on a site that never had them originally....but I guess...you guessed it I am knind a confused....

Or perhaps I could just have them come up in a new browser window...that would make my browsers still on site...
But somehow I feel better framing, there is that word...'framing' their page in mine, which they do not mind...

You advise me...I do not know how technical or simple what I want is...really.


Checked the site, thanks for the script and colouring.

thanks

ACJavascript
Jul 3rd, 2002, 04:36 PM
If you don't want to use frames you could always use and iframe. AN iframe will let you load a site into it without changing the contents around it. Its like a frame but it isn't. I think for what your trying to do it might be better to go with the iframe;)

Thats my opion though, hehe so what your think?
I can help you code in the frames and in iframe so whatever you choose;)

Do you use AOL?
I ask this b/c we could get an IM going and i could help you all in one shot hehehe;)

peter
Jul 3rd, 2002, 11:42 PM
Great, I sent you a mail.