Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sarah on Oct 01, 2008 13:40
open dhtmlx forum
I need ComboBox to jump to url when option selected

Hi,

I downloaded ComboBox, and I'm trying to use the feature with images and external data.xml. I have two questions:

1. I have a list of urls I want to use for options, so when an option is selected, it jumps automatically to that url. How do you assign the value of an option as a url, and make it jump to that url when selected?

Here is an original code I had for the jump select list:

<form class= method="post" action="return false;">
<select onchange="location.href=this.value;">
<option value="http://www.yahoo.com/">Yahoo</option>
<option value="http://www.google.com/">Google</option>
</select>
</form>


2. I read your guide on how to implement the ComboBox with images, but it didn't work. Can you please help. Here is what I have:

Inside the data.xml file I have:

<?xml version="1.0" ?>
<complete>
<option value="http://www.yahoo.com/" img_src="images/yahoo.gif">Yahoo</option>
<option value="http://www.google.com/" img_src="images/google.gif">Google</option>
</complete>

Inside the html page I have:

    <script>
        window.dhx_globalImgPath="images/";
    </script>

    <script src="dhtmlxcommon.js"></script>
    <script src="dhtmlxcombo.js"></script>
    <script src="dhtmlxcombo_extra.js"></script>

<div id="combo_zone2" style="width:320px; height:100px;">

<script>
var z=new dhtmlXCombo("combo_zone2","alfa2",320, 'image');
z.setDefaultImage("images/default.gif");
z.loadXML("data.xml");</script>

Thanks.
Answer posted by Support on Oct 02, 2008 02:14
>>Here is an original code I had for the jump select list:
Combo has onChange event which can be used for the same purpose. 

combo = new dhtmlXCombo(...
combo.addOption([["http://www.yahoo.com/","Yahoo"],["http://www.google.com/","Google"]]);
combo.attachEvent("onChange",function(){
     document.location.href = this.getActualValue();
});
Answer posted by Support on Oct 02, 2008 02:17
>>but it didn't work
Please check attached sample. 
Attachments (1)
Answer posted by Sarah on Oct 02, 2008 10:47
Thank you so much for your help. It works like magic. Have a great day :)