forms - Echo after dropdown seletion in php -


i'm new in php, need help. have xml file containing information's song name, author name , id. use xml file import song names drop down menu.

after visitor selects song name drop down menu, should author name, don't know how create this.

here xml file:

<songs> <song>     <name>i left heart on europa</name> <author>author name 1</author>     <id>1</id> </song> <song>     <name>oh ganymede</name> <author>author name 2</author>     <id>2</id> </song> <song>     <name>kallichore</name> <author>author name 3</author>     <id>3</id> </song> 

and php file:

<?php $songs = simplexml_load_file('rss.xml'); echo "<select id='selsongs'>"; foreach($songs $song) { echo "<option value='".$song->id."'>".$song->name."</option>"; } echo "</select>"; ?> 

best regards, milan

additional comment:

after better reading code, see want receive author name (which know, because in received xml).

there way you

use data-* attribute in html

<select class="songs">     <option value="1" data-author="author name 1">i left heart on europa</option>         <option value="2" data-author="author name 2">oh ganymede</option>         <option value="3" data-author="author name 3">kallichore</option> </select> 

and catch using jquery

$(".songs").change(function() {     var author = $("select option:selected").attr("data-author");     $(".author").text(author); }); 

note

you need include jquery html.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 

example: http://jsfiddle.net/ypzc6/


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -