XSLT and PHP

Discussion in 'PHP' started by girish3110, Apr 12, 2008.

  1. #1
    I have the following xml file:
    
    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="sound.xsl"?>
    <sound>
    <sample>
    <title>sample1</title>
    <url>http://www.example.com/sample1.mp3</url>
    </sample>
    <sample>
    <title>sample2</title>
    <url>http://www.example.com/sample2.mp3</url>
    </sample>
    </sound>
    
    Code (markup):
    I am having problems when trying to incorporate a combo box in its XSLT. The combo's value should be the URL and the caption should be the title. How do I do it? I just want the help with the combo box part.

    Secondly, I am using php's plugin to load the xml file into a php page. How do I retrieve the value of the combo on that page?
     
    girish3110, Apr 12, 2008 IP
  2. girish3110

    girish3110 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Huh,I will make my request simple:

    Anyone has got a simple tutorial on how to use a combo box in XSLT?
     
    girish3110, Apr 13, 2008 IP
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Do you have the transformation [xsl] file?
     
    m0nkeymafia, Apr 13, 2008 IP
  4. girish3110

    girish3110 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've managed to do the xslt and it's working fine. Next,how do I get the value from the combo box with javascript?
     
    girish3110, Apr 13, 2008 IP
  5. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #5
    This should probably be in the javascript forum then?
    Why not google javascript combo box

    First result
     
    m0nkeymafia, Apr 13, 2008 IP
  6. girish3110

    girish3110 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I know how to get the value. I am using the xslt and xml file together to output another page that shows the combo box with its values as specified in the XSLT. Here is the php page:
    
    <?php
    	$xsltproc=xslt_create();
    	$xslt_result=xslt_process($xsltproc,'../www/test/sounds.xml','../www/test/sounds.xsl');
    	xslt_free($xsltproc);
    ?>
    
    ..............
    ..............
    <form name="frm_Listen">
    <table width="370" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
    <td width="156"><div align="center"><span class="style14 style15">Choose Sound: </span></div></td>
    <td width="210"><div align="center"><span class="style14 style15">
    <?php
    print $xslt_result; //XML File Output here
    ?>
    </span></div></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><br><input type=button name="but_Listen" value="Listen" onClick="Listen();"></div><div align="center"></div></td>
    </tr>
    </table>
    </form>
    
    Code (markup):
    The output is a combo box with the different values between the <form></form> tags. The Listen() function is as follows:
    
    <script type="text/javascript">
    
    function Listen() 
    {
    	var x;
    	var width  = 500;
    	var height = 350;
    	var left   = (screen.width  - width)/2;
    	var top    = (screen.height - height)/2;
    	var params = 'width='+width+', height='+height;
    	params += ', top='+top+', left='+left;
    	params += ', directories=no';
    	params += ', location=no';
    	params += ', menubar=no';
    	params += ', resizable=no';
    	params += ', scrollbars=no';
    	params += ', status=no';
    	params += ', toolbar=no';
    
    	x=document.forms[0].sel_Sounds.value; //This part needs to be modified
    
    	url="Listen.php?ID="+x;
    	newwin=window.open(url,'Listen', params);
    	if (window.focus) 
    	{
    		newwin.focus()
    	}
    	return false;
    }
    </script>
    
    Code (markup):
    I need to modify the x=document.forms[0].sel_Sounds.value; part so that it takes the value of the combo that was specified in the XSLT. So,how do I do it?
     
    girish3110, Apr 15, 2008 IP