Using an onchange()

I there a way I can run some PHP code when the select box (member name) is changed?
This is what im thinking…


    <select name="m_name" class="form-control" id="name" onChange="<?php findName(); ?>">

then


function findName() {
...
}

Am I on the right track here?

I sometimes use this for Select or Radio buttons. No extra JS needed.

 onchange="this.form.submit()"

Well no… not really. You need to use AJAX. PHP is run on the server, not the client. You’re trying to run it from the client.

Are you using jQuery? If not, I suggest it. If there’s any reason to start using it on your site, it’s when you start using AJAX.

You’re going to need to return something like a json object then populate whatever you’re trying to do with your names in Javascript.

http://api.jquery.com/jquery.ajax/

ok, got the thing I needed, the problem now is im trying to record the name (so I wont need to use AJAX)
Heres the option


<option value=3>Davida Milkes</option>

So I have the id (3) of davida being saved, but I want to save the name (Davida Milkes). The way I am thinking is I need to create an onchange event on the select box which places the text of the3 selected option as the value of the inmput box


<input type="text" name="m_name" value="">

is this good?
http://stackoverflow.com/questions/14861950/populate-text-field-with-value-of-selected-option-in-select-list