Hi! I'd like to ask your help. Using jquery-ajax select option function, how can I get the result when row is cross match with column. In the select option image I attached, how do I get the 625 value from my SQL table.(SQL DAtabase.jpg) if I select 3/4" in the first select option and 36" in the second Thanks in advance.
First create a web service:
<?php
$c1 = $_GET['dropbox1'];
$c2 = $_GET['dropbox2'];
mysql_connect("localhost","root","");
mysql_select_db("db_name");
$q = "select `column_name` from `table_name` where `column1`='$c1' AND `column2`='$c2'";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
echo $row[0];
Now call web service from Form Page
<html>
<script type="text/javascript">
$(document).ready(function () {
$("#option2").on("change", function() {
var link = "webservice.php?dropbox1=" + document.getElementById("option1").value + "&dropbox2=" + document.getElementById("option2").value;
$.get(link, function(data, status){
alert("Data: " + data + "\nStatus: " + status);
document.getElementById("answer").value = data;
});
});
});
</script>
<body>
<select id="option1"><option>option1</option><option>option1</option><option>option1</option></select>
<select id="option2"><option>option1</option><option>option1</option><option>option1</option></select>
<select id="answer"></select>
</body>
</html>
Note: Please change variables and column names accoridng to your script.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.