i want if user select one value in combo box that value should store in db and then display what they are selected. for example if user select CONFIRM option that value stored in db after that it display CONFIRM instead of that combo box form and button. Here i can stored the combo box values in db successfully. thats not a problem and then here i used ajax method to show the msg instead of button place. Now, i want what user select it should display the same value. check these above coding and reply me ur suggestions...

this is my combo box page coding:

echo "<form method=post align=center>
<div id=myDiv>
<select name=userselect>
<option value=empty></option>
<option value=Confirm> Confirm </option>
<option value=Processing> Processing </option>
<option value=Pending> Pending </option>
<option value=Cancelled> Cancelled </option>
<button type=button name=combobox value=combobox onclick=loadXMLDoc()>Update</button>

this is my php code (another page):

if (isset($_POST['combobox']))
    $userselect = $_POST['userselect'];
    echo $userselect;

Recommended Answers

All 2 Replies

Ok well it sounds like you already have the server side/ajax setup so all you have to do is attach an onChange listener to the select element.

var select = document.getElementById('select_id');
select.onChange = function() {
    // Get the selected value
    var value = this.options[this.selectedIndex].value;
    // Process change event

Also it's best practice to wrap all values to element attributes in double quotes.

<form method="POST" action="/myaction.php">

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.