I have a form, with 3 drop down menus on it.
The values of these drop down menus I'd like to come from an XML file that looks like the below:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manufacturers>
<manufacturer name="Audi">
<model name="A4">
<vtrim>1</vtrim>
</model>
<model name="A6">
<vtrim>1</vtrim>
</model>
<model name="A8">
<vtrim>1</vtrim>
</model>
<model name="Quattro">
<vtrim>1</vtrim>
</model>
<model name="TT">
<vtrim>1</vtrim>
</model>
</manufacturer>
</manufacturers>
Now I am not entirely sure whether or not this is valid XML. But essentially, what I want to happen is have the Manufacturer's drop down box fill with just the manufacturer names, and then when one of those is selected, it determines the values in the box below it for the Models - preferrably without reloading the page.
Is there an easy way to do this using what I have above or have I done it completely wrong?
What I've tried to do so far is do it using PHP5. Just to debug and check I could pull values from the XML data, I used the following code:
Code:
if(!$xml=simplexml_load_file('Vehicles.xml')){
trigger_error('Error reading XML file',E_USER_ERROR);
}
echo 'Displaying contents of XML file...<br />';
foreach($xml as $makes){
echo 'Name: '.$makes->manufacturer.' Model: '.$makes->model.'
Trim: '.$makes->vtrim.'<br />';
}
But all it prints our to screen is '; foreach($xml as $makes){ echo 'Name: '.$makes->manufacturer.' Model: '.$makes->model.' Trim: '.$makes->vtrim.'
'; } ?>
Please help, I need to get this up and running as soon as I can!
Liam Gulliver,
http://p2p.neopian-hosting.com
A New Programming Chat Forum