ajax接收text文本框的值,如何使用Ajax或Jquery填充文本框中的值?

Example- Consider three textboxes. In the first one, im providing ID or number ( primary key in my table). Using the ID, the semester and branch should be auto filled using the ID. ( All the three fields are in same table- in my DB). HTML part:

示例 - 考慮三個文本框。在第一個,我提供ID或數字(我的表中的主鍵)。使用ID,學期和分支應使用ID自動填充。 (所有這三個字段都在我的數據庫中的同一個表中)。 HTML部分:

PHP,Mysql part:

PHP,Mysql部分:

session_start();

$hostad=$_POST['hosteladmissionno'];

$sem=$_POST['student_name'];

$sem=$_POST['semester'];

$r1="INSERT INTO payment(hosteladmissionno)VALUES ('$hostad')";

Now i want the fields student_name and semester to be autofilled for the correspoinding hosteladmissionno. Can this be done by Ajax or Jquery? If so.. How can i implement in this Code? Note: hosteladmissionno,student_name and semester belongs to registration tablem in my database. I need to retrieve the values from that table.Thanks in advance.

現在我希望字段student_name和semester被自動填充為correspoinding hosteladmissionno。這可以通過Ajax或Jquery完成嗎?如果是這樣..我如何在本規范中實施?注意:hosteladmissionno,student_name和semester屬於我的數據庫中的注冊tablem。我需要從該表中檢索值。提前謝謝。

1 个解决方案

#1

1

What do you mean auto-filled? The query that you've provided only the hosteladmissionno will be inserted. Unless you have a default value for the other column. But if you intended to insert the text you forward, you should also add it in your insert value. Something like this.

你是什​​么意思自動填充?將插入您僅提供hosteladmissionno的查詢。除非您有另一列的默認值。但是,如果您打算插入前進文本,則還應將其添加到插入值中。像這樣的東西。

$r1 = "INSERT INTO payment(hosteladmissionno, student_name, semester)VALUES ('$hostad','$sem_student_name','$sem_semester')";

I don't know why you use the same variable in two different field. Does only the last initialization will be its value.

我不知道為什么你在兩個不同的領域使用相同的變量。只有最后一次初始化才是它的值。

See some tutorials:

看一些教程:

通過jQuery使用AJAX發布MySQL結果

JQuery Ajax

PHP標簽

jquery - > php - > mysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值