In my index file where the form and function are located, named:
index.php
$(function() {
$.ajax({
type: "POST",
url: "invtype.php",
data: "getrevenuetype=true",
success: function(b){
$("#revenueType").html(b)
}
})
})
<span name="revenueType" id="revenueType"></span><br/>
invtype.php
<?php
mysql_connect("","","") or die('Error: '.mysql_error());
mysql_select_db("dbname");
if(isset($_POST['getrevenuetype'])) {
$sql3 = mysql_query("SELECT * FROM chartofaccount WHERE accountnumber >= 4000 and accountnumber <= 4999");
$acct = '';
$acctrow = mysql_num_rows($sql3);
if($acctrow > 0) {
echo 'Revenue Type:<select name="rename">';
while($chartrow = mysql_fetch_array($sql3)) {
$revenueaccountname = $chartrow['accountname'];
$acct .= '<option value="$revenueaccountname"> '. $revenueaccountname .' </option>';
}
}
}
echo $acct;
echo '</select>';
My question is how will I get or what code should I put on to get the value of the option selected by the user? My purpose in getting the value is that I want to put it in another php where it will be used as var in inserting data into MySQL. already tried this code: $name = $_POST['rename']; then included ‘invtype.php’; on the other php file (this is where I will use the value of option selected) but it doesn’t seem to work. I know my code is all messed up and I’m really sorry about it, but guys if you can help I would really appreciate it.
you need to add , for example, ‘ for first time response
than add js
than change invtype.php