|
-
April 17th, 2008, 03:16 AM
#1
XSLT,XML and PHP
Firstly, here is my XML file:
Code:
<?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>
My XSLT:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<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; //Modify this part
url="Listen.php?ID="+x;
newwin=window.open(url,'Listen', params);
if (window.focus)
{
newwin.focus()
}
return false;
}
</script>
</head>
<body>
<form>
<table border="0" align="center">
<tr>
<td>
<select id="sel_Sounds">
<xsl:for-each select="sound/sample">
<option>
<xsl:attribute name="value"><xsl:value-of select="url"/></xsl:attribute>
<xsl:value-of select="title"/>
</option>
</xsl:for-each>
</select>
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="Listen" onClick="Listen();"/>
</td>
</tr>
</table>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I need to pass the value of the combo box to the Listen.php file. How do I access that value in the combo box?
-
April 17th, 2008, 07:08 AM
#2
Re: XSLT,XML and PHP
Any element that is to be processed by a form must have a name attribute. So give it a name, and then you can access it in the PHP page by using $_GET['element_name'] or $_POST['element_name'].
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 17th, 2008, 07:50 AM
#3
Re: XSLT,XML and PHP
I get the following error:
Notice: Undefined index: sel_Sounds in c:\program files\easyphp1-8\www\test\capture.php on line 10
-
April 17th, 2008, 08:05 AM
#4
Re: PHP grab value from combo box
You haven't mentioned anything about that file before. Undefined index means that you are attempting to access an index within an array that does not exist. Double check your array.
And this has nothing to do with XML.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 17th, 2008, 08:06 AM
#5
Re: PHP grab value from combo box
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 18th, 2008, 01:08 AM
#6
Re: PHP grab value from combo box
Can anyone help? Will it work if the XML and XSLT are modified?
-
April 18th, 2008, 08:26 AM
#7
Re: PHP grab value from combo box
How can anyone help if you aren't making any sense, nor posting any code. Did you check for the array index as I already mentioned?
 Originally Posted by girish_mu
Will it work if the XML and XSLT are modified?
Why would server-side code accessing a drop down change by XML unless you were filling the drop down with the XML?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 18th, 2008, 12:28 PM
#8
Re: PHP grab value from combo box
I had tried capturing the data from the combo by submitting the form to a page called capture.php and I used the following piece of code:
Code:
$captured_data=$_REQUEST['sel_Sounds'];
And I got the error mentioned in a previous post. Have you tried the XML and XSLT? The combo is being filled with data from the XML file.
-
April 21st, 2008, 10:41 AM
#9
Topic Closed
I have found the error and it's working fine now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|