If you want an easy way and not so hard to manage then I suggest using an AJAX sort of request and you can code a PHP file that handles the request then the JS http request fetches the HTML result.

Here is an example http://w3schools.com/php/php_ajax_database.asp which uses onchange and GET it's very simple.
Scandium Reviewed by Scandium on . Problem using javascript in form field I am looking to show few extra form fields depending on the selection from a drop down menu. For eg. in a drop down asking for payment option if i select Online bank transfer then it should create/show a new form field below it asking for bank account number and name. And, if i select paypal then it should ask for paypal id. I have made this code which is working fine when i dont use form tag.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" Rating: 5