在php中动态更改文本

hey guys i am building a form in which i want when a user select an option from the dropdown menus a text to be displayed and calculate the price.

The dropdown menu is:

<select id="recipient" name="recipient" tabindex="6" class="selmenu">  
            <option value="staff">Site Staff</option>  
            <option value="editor">Editor-in-Chief</option>  
            <option value="technical">Tech Department</option>  
            <option value="pr">Public Relations</option>  
            <option value="support">General Support</option>  
        </select>

and the other dropdown menu is:

<select id="recipient" name="recipient" tabindex="6" class="selmenu">  
            <option value="one">1</option>  
            <option value="two">2</option>  
            <option value="three">3</option>  
            <option value="four">4</option>  
            <option value="five">5</option>  
        </select>

What i want to do is when the user selects something from the first and the second menu i want a textfield to change dynamically... can anyone point me the way?

only ajax/jquery could do that in combination of php step might be...

  1. onchange of any dropdown make a ajax request to php script.

  2. return the json response from php script

  3. use this response to either manipulate your form or display data on page.

you don't need to use php for this, it can all be done with jquery/javscript

an example using jquery is below (i had to rename your second select as you had re-used an ID):

$('.selmenu').change(function() {
  $('#output').text($('#recipient option:selected').text() + ' ' + $('#recipient2 option:selected').text());
})

output is the id of your textbox.

on a select value being changed, output will be filled with the selected value in both select controls