hp表
id name(货品名称) kucun(库存) danwei(单位) danjia(出库单价) tiaoma(条码)
1 ................................................................................................................. 1234
回复讨论(解决方案)
并且每次扫完读取到货品后,自动将文本tiaoma清空(以便扫另一个物品),并且光标显示在文本tiaoma里
你需要用到ajax
你需要用到ajax
请帮忙写一下
有人帮忙写下吗?
是扫了条形码后跳转到这个页面吗?
select * from hp where tiaoma='1234';
找到记录后echo出来。
是扫了条形码后跳转到这个页面吗?
select * from hp where tiaoma='1234';
找到记录后echo出来。
我的意思是,每扫一个就在下面显示一个,扫几个就显示几个
扫完,提交到php,然后返回内容,用js加一个table就可以了。
ajax操作。
问题是你扫的程序是怎样的。
扫完,提交到php,然后返回内容,用js加一个table就可以了。
ajax操作。
问题是你扫的程序是怎样的。
不会AJAX,你能帮忙写一下吗?
扫的程序就是一个表单提交,在文本框里扫了条码后,文本框里就会出现一串数字,然后再提交
在网上搜到一个类拟的:
<script></script>
<script> <br /> $(document).ready(function (){ <br /> //$("#name").focus(); input框输入内容然后刷新页面,input框内容还在(firefox) <br /> clearText(); // 改用clearText <br /> $("#addBtn").click(function (){ <br /> $("#table1").append(getNewRow()); <br /> clearText(); <br /> }); <br /> $("#table1").on('click', ".delBtn", function (){ <br /> $(this).parent().parent().remove(); <br /> }); <br /> }); <br /> function clearText(){ <br /> $("#name").val(""); <br /> $("#name").focus(); <br /> } <br /> function getNewRow(){ <br /> var btn = $("<input class='delBtn' type='button' value='删除' />"); <br /> var newRow = $("<tr>").append($("<td>").append( $("#name").val())) <br /> //1、怎么在这里提交到PHP? <br /> //2、怎么让红色$("#name").val()这个显示为PHP返回来的数据库的值? <br /> .append($("<td>").append(btn)); <br /> return newRow; <br /> } <br /> </script>
名称: |
名称 | 操作 |
3、怎么在这个里输入条码后直接添加一行,而不需要点击??
http://www.cnblogs.com/Johnny_Z/archive/2012/06/17/2552597.html
为什么下面的代码不行呢?错在哪呢?
<script> <br /> $(document).ready(function (){ <br /> //$("#name").focus(); input框输入内容然后刷新页面,input框内容还在(firefox) <br /> clearText(); // 改用clearText <br /> $("#addBtn").click(function (){ <br /> $("#table1").append(getNewRow()); <br /> clearText(); <br /> }); <br /> $("#table1").on('click', ".delBtn", function (){ <br /> $(this).parent().parent().remove(); <br /> }); <br /> }); <br /> function clearText(){ <br /> $("#name").val(""); <br /> $("#name").focus(); <br /> } <br /> <br /> function getNewRow(){ <br /> $.get("/oa/oa_api.php?act=get_oa_vip",{ //为什么这里没有用 <br /> vip:$("#name").val(), <br /> async:false, <br /> rand: Math.random() <br /> },function(data){ <br /> if(data.status.code=="1") <br /> { <br /> //成功 <br /> var jifen = data.record.jifen; <br /> var xy_id = data.record.xy_id; <br /> var btn = $("<input class='delBtn' type='button' value='删除' />"); <br /> var newRow = $("<tr>").append($("<td>").append(xy_id)) <br /> .append($("<td>").append(jifen)) <br /> .append($("<td>").append(btn)); <br /> return newRow; <br /> } <br /> else <br /> { <br /> alert('读取数据错误!'); <br /> } <br /> },"json"); <br /> } <br /> </script>
名称: |
名称 | 操作 |
oa_api.php如下:
if($action == 'get_oa_vip')
{
if ( !(isset($_SESSION['userid']) && $_SESSION['userid'] > 0) )
{
ajax_error('请先登录!');
exit;
}
//取school_id 如果没有school_id则退出
$sql = "select schoolID from " . $fdyu->table('users') . " where user_id=" . $_SESSION['userid'];
$school_id = $db->getOne($sql);
if($school_id {
ajax_error('您不属于任何学校,无法使用该功能!');
exit;
}
$vip = $_GET['vip'];
$ajax = array();
$sql = "select xy_id,jifen from " . $fdyu->table('oa_vip') . " where vip='" . $vip . "' and school_id=" . $school_id . "";
$res = $db->query($sql);
if($res)
{
$ajax['status']['code'] = '1'; //成功
$ajax['record']['jifen'] = $row['jifen'];
$ajax['record']['xy_id'] = $row['xy_id'];
}
echo json_encode($ajax);
exit;
}
经过一层层排查,PHP返回的值也获取到了,现在就是不知道怎么把获取到的值放到
名称 | 操作 |
这个里去,也就是下面这一段有问题,请问应该怎么写?
var newRow = $("
.append($("
.append($("
return newRow;
$,post(url,{args:args},function(data){
alert(data);
})
通过异步获取结果集
$.ajax({
type: "POST", //用POST方式传输
url: 'f.php', //目标地址.
dataType: "json", //数据格式:JSON
//data: "dealType=" + dealType +"&uid=" + uid + "&code=" + code,
data: "&a="+mobile,
success: function(json){
if(json.msgid==1){//成功的处理
alert(json.html);
}
else if(json.msgid==2){//失败的处理
alert(json.html);
}
else{
alert(json.html);
}
}
});
成功后,用jquery事件,加入
var newRow = $("
.append($("
.append($("
return newRow;
试下
现在我的程序已经能正常获取到返回的值,
if(data.status.code=="1")
{
//成功
var jifen = data.record.jifen;
var xy_id = data.record.xy_id;//这里能正常获取到了
....
现在我的问题就是,怎么将获取到的值插入到下面的table里
名称 | 积分 | 操作 |
谁能告诉我怎么写?
现在我的程序已经能正常获取到返回的值,
if(data.status.code=="1")
{
//成功
var jifen = data.record.jifen;
var xy_id = data.record.xy_id;//这里能正常获取到了
....
现在我的问题就是,怎么将获取到的值插入到下面的table里
名称 | 积分 | 操作 |
只需要回答我这个问题就行了,不要写新的方法了
都一个月了,还没解决?
网上动态添加表行的 js 代码多了去了,一个月都找不到适合你的?
不知道搜什么关键字,所以一直等答案
现在就差最后一步了,拜托帮我写一下,我现在去网上搜肯定与我现在写的不一样,我又得研究老久了
有人帮忙写一下不?
<table id="table1" border="1"> <tr> <td>名称</td> <td>积分</td> <td>操作</td> </tr></table><script>var t = document.getElementById('table1');var tr = t.insertRow();var td1 = tr.insertCell();td1.innerHTML = 1;var td2 = tr.insertCell();td2.innerHTML = 2;var td3 = tr.insertCell();td3.innerHTML = 3;</script>
能看明白吗?
可以了,谢谢
但还有一个问题麻烦一下你,就是同一条码不能重复添加应该怎么弄?
弄好了
换了种写法:
function getNewRow(){
$.get("/oa/oa_api.php?act=get_oa_vip",{
vip:$("#name").val(),
async:false,
rand: Math.random()
},function(data){
if(data.status.code=="1")
{
//成功
var jifen = data.record.jifen;
var xy_id = data.record.xy_id;
if( $("#tr_"+xy_id).length > 0 )
{
clearText();
return false;
}
var btn = '';
var trHtml;
trHtml = '
trHtml += '
trHtml += '
trHtml += '
$("#table1").append(trHtml);
clearText();
}
},"json");
}

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
