PDA

View Full Version : How do I make the window widget pop up in a drop down list?



tivaelydoc
07-02-2007, 07:30 PM
1) Script Title: window widget

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem:
I want to make the window widget pop up from a drop down list

I have a basic drop down menu:


<select name="menu">
<option value="#">blah</option>
<option value="#">blah</option>
<option value="http://example.htm">blah</option>
</select>
<a href="javascript:jumpMenu()"><IMG SRC="http://img36.picoodle.com/img/img36/8/6/29/f_heartm_abbd3e9.png" border=0></a>
</form></td>

and i want to make the window widget pop up from it, let's say:


<a href="#" onClick="examplewin=dhtmlwindow.open('ASDF!', 'iframe', 'example.com', 'ASDF', 'width=1337px,height=666px,center=1'); return false">ASDF!</a>

So how would I?

ddadmin
07-03-2007, 05:40 AM
Do you mean use a drop down menu to launch a DHTML window based on the value of the selected option? Something like this would work:


<script type="text/javascript">

function loadwindow(selectedoption){
iframewin=dhtmlwindow.open("examplebox", "iframe", selectedoption.value, selectedoption.text, "width=590px,height=350px,resize=0,scrolling=1,center=1")
}

</script>

<select onChange="loadwindow(this.options[this.selectedIndex])">
<option value="http://google.com">Example</option>
<option value="http://yahoo.com">Example 2</option>
<option value="http://digg.com">Example 3</option>
</select>

tivaelydoc
07-03-2007, 07:13 AM
I mean, what about the button? I tried the code, but don't I have to change the code for the button?

ddadmin
07-03-2007, 07:35 AM
Do you mean a form button that's associated with the select menu, so that clicking on it would also load the DHTML window based on the selected option value?

tivaelydoc
07-03-2007, 07:52 AM
Yes sort of. Currantly, my button is

<a href="Javascript:jumpMenu()"><IMG SRC="http://example.jpg" border=0></a>

I don't want the window to pop up when the option is select, but instead when the button is clicked after it is selected.

ddadmin
07-03-2007, 07:29 PM
Sure. Instead of the code I posted above, try the following instead:


<script type="text/javascript">

function loadwindow(selectid){
var selectelement=document.getElementById(selectid)
var selectedoption=selectelement.options[selectelement.selectedIndex]
iframewin=dhtmlwindow.open("examplebox", "iframe", selectedoption.value, selectedoption.text, "width=590px,height=350px,resize=0,scrolling=1,center=1")
}

</script>

<form>
<select id="winlist">
<option value="http://google.com">Example</option>
<option value="http://yahoo.com">Example 2</option>
<option value="http://digg.com">Example 3</option>
</select> <a href="#" onClick="loadwindow('winlist')">Load Selected Window</a>
</form>

tivaelydoc
07-03-2007, 07:55 PM
Thanks a lot man. It worked.

rodrigomc
12-15-2007, 08:11 PM
Hi to all, i'am new user on this forum...

i use this script posted by ddadmin and work fine:

<script type="text/javascript">

function loadwindow(selectid){
var selectelement=document.getElementById(selectid)
var selectedoption=selectelement.options[selectelement.selectedIndex]
iframewin=dhtmlwindow.open("examplebox", "iframe", selectedoption.value, selectedoption.text, "width=590px,height=350px,resize=0,scrolling=1,center=1")
}

</script>

<form>
<select id="winlist">
<option value="http://google.com">Example</option>
<option value="http://yahoo.com">Example 2</option>
<option value="http://digg.com">Example 3</option>
</select> <a href="#" onClick="loadwindow('winlist')">Load Selected Window</a>
</form>

but i have 2 questions:

1 - How i can cancel this script for one especific option? example:

<select id="winlist">
<option value="OPEN ONE PAGE WHEN CLICK HERE">Example</option>
<option value="OPEN ONE PAGE WHEN CLICK HERE">Example 2</option>
<option value="NOT OPEN ANY PAGE WHEN CLICK HERE">Example 3</option>
</select>

2 - Other question is:

When i open a window using this script what i need make to if the page have a link if i click not open the link in the same window but in master window (used to open a popup)

Sorry for my bad english, if yours not understand i can try explain again...

Thank youuuu

rodrigomc
12-17-2007, 03:25 PM
Please, someone help me, is what I asked is possible or is not done using this script?

ddadmin Can you help me?

ddadmin
12-18-2007, 06:31 AM
Hi rodrigomc:
Sorry for the delay in responding. To answer your questions:

1) Try the below:


<script type="text/javascript">

function loadwindow(selectid){
var selectelement=document.getElementById(selectid)
var selectedoption=selectelement.options[selectelement.selectedIndex]
if (!/ignore/i.test(selectedoption.className))
iframewin=dhtmlwindow.open("examplebox", "iframe", selectedoption.value, selectedoption.text, "width=590px,height=350px,resize=0,scrolling=1,center=1")
}

</script>

<form>
<select id="winlist">
<option value="http://google.com">Example</option>
<option value="http://yahoo.com" class="ignore">Example 2</option>
<option value="http://digg.com">Example 3</option>
</select> <a href="#" onClick="loadwindow('winlist')">Load Selected Window</a>
</form>

In other words, you can give options that you don't wish to launch a DHTML window a class name of "ignore".

2) A DHTML window is really just an IFRAME on the page, so to have links that appear within it load in the main page, just give them a target="_top" attribute. Of course, this only works if you have access to the external page (ie: both pages are within your own domain).

rodrigomc
12-18-2007, 04:26 PM
ddadmin thank you very much! you is the best!