本文是小编为大家收集整理的关于用于多个页面的外部Js dosent工作的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。
问题描述
你好,
我是 Ajax 和 Javascript 的新手,我有一个疑问...
我有一个外部 javascript.和几个 html 文件,我通过 ajax 请求和响应加载这些文件.
html 页面依次包含几个图像标签、复选框和输入标签
单击时,我获取复选框的 ID ........ 当我浏览页面时,这有效. 但是当我获取相应复选框的值时......我浏览页面.
此外,当一个复选框被选中时,即使我浏览页面,我也需要显示它们被选中.
如果我能在你的帮助下前进,那就太好了.
感谢您提前回复....
推荐答案
Sorry i Dosent Work If I take the value of the Input Tag OF the Corresponding Check Box...
建议PLS......
你能发布一些代码.
这是我的第一页.
<身体>
<表格边框="0"cellpadding="0">
<tr>
<td>
<div id="product_1">
<表格边框="0"cellpadding="0">
<tr>
<td></td></tr>
<tr>
<td id="cost1";样式="字体粗细:粗体";值="78";disabled=true>Rs.78</td>
<td id="seltd1"><输入类型="复选框"名称="购物产品"id="checkImage1"></td>
</tr>
<tr>
<td>数量</td>
<td id="qty1";样式="字体粗体:粗体"><输入类型="文本"id="sqty1";大小="3";maxlength="3"></td></tr>
</tr>
</表>
</div>
</td>
<td>
<div id="product_2">
<表格边框="0"cellpadding="0">
<tr>
<td></td><tr>
<tr>
<td id="seltd2"><输入类型="复选框"名称="购物产品"id="checkImage2"></td>
<td id="cost2";样式="字体粗细:粗体";值="400"disabled=true>Rs.400</td>
</tr>
<tr>
<td>数量</td>
<td id="qty2";样式="字体粗体:粗体"><输入类型="文本"id="sqty2";大小="3";maxlength="3"></td></tr>
</tr>
</表>
</div>
</td>
---第一页的一部分.10以内的产品也是一样
函数调用的页面末尾
<div class="clearCart"id="添加到购物车";onclick="AddtoCart();">加入购物车</div>
</div>
</div>
</div>
<表格对齐="右"边界="0";style="padding-right:200px">
<tr>
<td><输入类型="按钮"id="上一个";禁用="真";值="<<上一个"onClick="nextPage(''prevPg'');"></td>
<td></td>
<td><输入类型="按钮"value ="下一个>>"id="下一个";onClick="nextPage(''nextPg'');"></td>
</tr>
</表>
************************************************************************************************
这是我的第二页.
<div style="font-weight:bold">产品页面2
<表格边框="0"cellpadding="0">
<tr>
<td>
<div id="product_11">
<表格边框="0"cellpadding="0">
<tr>
<td></td></tr>
<tr><td id="seltd11"><输入类型="复选框"名称="购物产品"id="checkImage11"></td>
</tr>
<tr>
<td>数量</td>
<td id="qty11";样式="字体粗体:粗体"><输入类型="文本"id="sqty11";大小="3";maxlength="3"></td></tr>
</tr>
</表>
</div>
</td>
<td>
<div id="product_12">
<表格边框="0"cellpadding="0">
<tr>
<td></td></tr>
<tr><td id="seltd12"><输入类型="复选框"名称="购物产品"id="checkImage12"></td>
</tr>
<tr>
<td>数量</td>
<td id="qty12";样式="字体粗体:粗体"><输入类型="文本"id="sqty12";大小="3";maxlength="3"></td></tr>
</tr>
</表>
</div>
</td>
<td>
<div id="product_13">
<表格边框="0"cellpadding="0">
<tr>
<td></td></tr>
<tr><td id="seltd13"><输入类型="复选框"名称="购物产品"id="checkImage13"></td>
</tr>
<tr>
<td>数量</td>
<td id="qty13";样式="字体粗体:粗体"><输入类型="文本"id="sqty13";大小="3";maxlength="3"></td></tr>
</tr>
</表>
</div>
</td>
<td>
本页以11到20的产品结束,本页没有找到或调用os js的函数
******************************************************************************************
带有被调用函数的Js文件
var productAry = 新数组;
var theObj ="";
document.onclick = function(e){
var theObj = e.target ||event.srcElement;
var theId ="";
if(theObj.type == "复选框"){
var theId = theObj.id
if(theObj.checked){
if(!productAry.inArray(theId))
for(var i=0;iif(theId == imageAry[i]){
productAry.push(imageAry[i]);
}
}
函数 AddtoCart(){
var topDiv = "<table border=''1''><tr><td colspan=''4'' align=''center'' style=''border:1px solid red;font-重量:粗体''>精选项目</td></tr>"
topDiv += "<tr style=''font-weight:bold''><td></td><td>Cost/Item</td></td>No.Of Items已订购</td><td>总计</td></tr>>>
for(var i=0;ivar addId = imageAry[i];
//var selQty = addId.findandreplace("checkImage","sqty");
//var selCost = addId.findandreplace("checkImage","cost");
//var selQtyValue = document.getElementById(selQty).value
//var selCostValue = document.getElementById(selCost).innerHTML;
//selCostValue = selCostValue.substring(3);
//if(document.getElementById(selQty).value !=""){
topDiv +="";
//topDiv +="<td><input type =''checkbox'' id=checked"+i+"已检查></td>>>
//topDiv +="Rs."+selCostValue+" "
//topDiv +="//topDiv +="<td>"+selCostValue*selQtyValue+"</td></tr>>
topDiv +="<td>"+addId+"</td></tr>>"
//}
//否则
//alert("请输入数量");
}
topDiv +="<tr><td colspan=''5''><input type=''Button'' value=''Buy The List'' onClick='''' </td></tr>>
topDiv +="</table>";
//if(document.getElementById(addId).checked && document.getElementById(selQty).value != ""){
document.getElementById("cartid").innerHTML = topDiv;
document.getElementById("cartid").style.display="b lock";
//}
...跳这有帮助.
期待..
提前致谢
本文地址:https://www.itbaoku.cn/post/1050547.html
问题描述
hi,
Im new into Ajax and Javascript, I have a doubt...
I have a External javascript. and a couple of html files and I load These through ajax request and response.
The html pages contain a couple of image tag a check box and a input tag in order
on click i take the id of the check box ........ This works when i navigate through the page. but When i take the value of the corresponding checkbox ...... This dosent work when i navigate through the page.
Also When an check box is checked I need to show them checked even when i navigate through the pages.
It would be Great if i could move forward withyour help.
Thanks for your reply in advance....推荐答案
Sorry i Dosent Work If I take The value of The Input Tag OF the Corresponding Check Box...
Suggestions PLS......Can you post some code.This Is My First Page.
<body>
<div id="productsMain" class= "products">
<div id="products" style="font-weight:bold">Products Page1
<table border="0" cellpadding="0">
<tr>
<td>
<div id="product_1">
<table border="0" cellpadding="0">
<tr>
<td></td>
<td class="box" id="image1"> Image 1 </td>
</tr>
<tr>
<td id="cost1" style="font-weight:bold" value="78" disabled=true>Rs.78</td>
<td id="seltd1"><input type = "checkbox" name = "shoppingProduct" id="checkImage1"></td>
</tr>
<tr>
<td>Qty</td>
<td id="qty1" style="font-weight:bold"><input type="text" id="sqty1" size="3" maxlength="3"></td></tr>
</tr>
</table>
</div>
</td>
<td>
<div id="product_2">
<table border="0" cellpadding="0">
<tr>
<td></td>
<td class="box" id="image2"> Image 2 </td></tr>
<tr>
<tr>
<td id="seltd2"><input type = "checkbox" name = "shoppingProduct" id="checkImage2"></td>
<td id="cost2" style="font-weight:bold" value="400" disabled=true>Rs.400</td>
</tr>
<tr>
<td>Qty</td>
<td id="qty2" style="font-weight:bold"><input type="text" id="sqty2" size="3" maxlength="3"></td></tr>
</tr>
</table>
</div>
</td>
--- Part of the first page. it is the same for products up to 10
The end of the page where the function is called
<div class="clearCart" id="AddtoCart" onclick="AddtoCart();">Add to Cart</div>
</div>
</div>
</div>
<table align="right" border="0" style="padding-right:200px">
<tr >
<td><input type="button" id="previous" disabled="true" value ="<< prev" onClick="nextPage(''prevPg'');"> </td>
<td> </td>
<td><input type="button" value ="next >>" id="next" onClick="nextPage(''nextPg'');"> </td>
</tr>
</table>
<div id="cartid" style="position:absolute;left:700px;background:#FF FF66;border:1px dashed gray;top:20px;display:none"></div>
************************************************** ***************************************
This is My Second Page.
<div style="font-weight:bold">Products Page2
<table border="0" cellpadding="0">
<tr>
<td>
<div id="product_11">
<table border="0" cellpadding="0">
<tr>
<td></td>
<td class="box" id="image11"> Image 11 </td>
</tr>
<tr>
<td id="cost11" style="font-weight:bold">Rs.300</td>
<td id="seltd11"><input type = "checkbox" name = "shoppingProduct" id="checkImage11"></td>
</tr>
<tr>
<td>Qty</td>
<td id="qty11" style="font-weight:bold"><input type="text" id="sqty11" size="3" maxlength="3"></td></tr>
</tr>
</table>
</div>
</td>
<td>
<div id="product_12">
<table border="0" cellpadding="0">
<tr>
<td></td>
<td class="box" id="image12"> Image 12 </td>
</tr>
<tr>
<td id="cost12" style="font-weight:bold">Rs.70</td>
<td id="seltd12"><input type = "checkbox" name = "shoppingProduct" id="checkImage12"></td>
</tr>
<tr>
<td>Qty</td>
<td id="qty12" style="font-weight:bold"><input type="text" id="sqty12" size="3" maxlength="3"></td></tr>
</tr>
</table>
</div>
</td>
<td>
<div id="product_13">
<table border="0" cellpadding="0">
<tr>
<td></td>
<td class="box" id="image13"> Image 13 </td>
</tr>
<tr>
<td id="cost13" style="font-weight:bold">Rs.55</td>
<td id="seltd13"><input type = "checkbox" name = "shoppingProduct" id="checkImage13"></td>
</tr>
<tr>
<td>Qty</td>
<td id="qty13" style="font-weight:bold"><input type="text" id="sqty13" size="3" maxlength="3"></td></tr>
</tr>
</table>
</div>
</td>
<td>
This page end with products from 11 to 20 no functions os js is found or called in this page
************************************************** ************************************
The Js File with the functions that are called
var productAry = new Array;
var theObj ="";
document.onclick = function(e){
var theObj = e.target || event.srcElement;
var theId ="";
if(theObj.type == "checkbox"){
var theId = theObj.id
if(theObj.checked){
if(!productAry.inArray(theId))
for(var i=0;i<imageAry.length;i++){
if(theId == imageAry[i]){
productAry.push(imageAry[i]);
}
}
function AddtoCart(){
var topDiv = "<table border=''1''><tr><td colspan=''4'' align=''center'' style=''border:1px solid red;font-weight:bold''> Selected Items</td></tr>"
topDiv += "<tr style=''font-weight:bold''><td></td><td>Cost/Item</td></td>No.Of Items Ordered</td><td>Total</td></tr>";
for(var i=0;i<imageAry.length;i++){
var addId = imageAry[i];
//var selQty = addId.findandreplace("checkImage","sqty");
//var selCost = addId.findandreplace("checkImage","cost");
//var selQtyValue = document.getElementById(selQty).value
//var selCostValue = document.getElementById(selCost).innerHTML;
//selCostValue = selCostValue.substring(3);
//if(document.getElementById(selQty).value !=""){
topDiv +="<tr>";
//topDiv +="<td><input type =''checkbox'' id= checked"+i+" CHECKED></td>"
//topDiv +="<td>Rs."+selCostValue+"</td>"
//topDiv +="<td align=''center''><input type = ''text'' id="+"sel"+selQty+" value="+selQtyValue+" size=''3'' ></td>"
//topDiv +="<td>"+selCostValue*selQtyValue+"</td></tr>"
topDiv +="<td>"+addId+"</td></tr>"
//}
//else
// alert("Please Enter the Quantity");
}
topDiv +="<tr><td colspan=''5''><input type=''Button'' value=''Buy The List'' onClick='''' </td></tr>"
topDiv +="</table>";
//if(document.getElementById(addId).checked && document.getElementById(selQty).value != ""){
document.getElementById("cartid").innerHTML = topDiv;
document.getElementById("cartid").style.display="b lock";
//}
...Hop This Helps.
Looking forward ..
Thanks in advance
相关标签/搜索qq邮箱可以使用smtp,但是谷歌不行 vba这么将数据写入ini文件指定节的键中 java 反射某个方法demo 调整learning rate 的技巧 python调api实现knn sh 文件 参数赋值变量 ctf题 @exec($_GET['cmd']) vuecli3构建多页面应用 js 获取月初前一星期时间 宿主机启动docker launchCamera不好用 centos7进入单用户模式115200 html iframe javascript filesystems jquery processing.js spring spring-security mod-rewrite cross-domain