I have a drop down field that is dynamically populated using an XML sheet that looks like:
[CODE]
<content>
<category link=”0″>
<title>Animals</title>
<xml>xml/animals.xml</xml>
</category>
<category link=”1″>
<title>Bagua 3 April</title>
<xml>xml/bagua.xml</xml>
</category>
<category link=”2″>
<title>Anthony Practice</title>
<xml>xml/Anthony.xml</xml>
</category>
</content>
I populate the dropdown box using javascript that looks like this:
[CODE]
<script type=”text/javascript”>
$(document).ready(function(){
$.ajax({
type: “GET”,
url: “galleries.xml”,
dataType: “xml”,
success: function(xml) {
var select = $(‘#mySelect’);
$(xml).find(‘category’).each(function(){
var title = $(this).find(‘title’).text();
select.append(“<option>”+title+”</option>”);
});
select.children(“:first”).text(“please make a selection”).attr(“selected”,true);
}
});
});
</script>
My the drop down form looks like this:
[CODE]
<form name=”myform” action=”dropdown.php” method=”post” enctype=”multipart/form-data”>
<select name=”selectBox” id=”mySelect” onChange=”document.myform.submit()”>
<option>loading</option>
</select>
</form>
When a user clicks on the drop down box, all of the values inside “<title>” tags get displayed. Once the user has made their selection, the form is submitted and posts the user’s option. My problem is that when the user clicks on the drop down box, I want them to see the content included in the “<title>” text but I want the form to post the data included in the “<xml>” tags.
For example, if the user clicks on the drop down menu and selects the option ‘Animals’ I want the form to post ‘xml/animals.xml’. Any ideas how to handle this?