我有一个看起来像这样的表单:
<form action="/vote/" method="post" class="vote_form">
<input type="hidden" name="question_id" value="10" />
<input type="image" src="vote_down.png" class="vote_down" name="submit" value="down" />
<input type="image" src="vote_up.png" class="vote_up" name="submit" value="up" />
</form>
Run Code Online (Sandbox Code Playgroud)
当我绑定到表单的submit($("vote_form").submit())时,我似乎无法访问用户单击的图像.所以我试图绑定到点击图像本身($(".vote_down, .vote_up").click()),它总是提交表单,无论我是否尝试
因为所有这些都是形式事件.
我应该将$ .post()附加到form.submit()事件,如果是这样,我如何判断用户点击了哪个输入,或者
我应该将$ .post()附加到图像点击,如果是这样,我该如何阻止表单提交.
这是我的jQuery代码现在的样子:
$(".vote_up, .vote_down").click(function (event) {
$form = $(this).parent("form");
$.post($form.attr("action"), $form.find("input").serialize() + {
'submit': $(this).attr("value")
}, function (data) {
// do something with data
});
return false; // <--- This doesn't prevent form from submitting; what does!?
});
Run Code Online (Sandbox Code Playgroud) 我在一个简单的页面上有一个jquery移动滑块.拖动滑块时,值会在文本框中按预期更新.我看了,但无法找到这种逻辑发生的地方.
我想要的是将值传递给javascript函数.如何将change事件绑定到我的函数?
干杯
麦克风.
下面的代码 - 请忽略一些讨厌的黑客:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Mobile Docs - Forms</title>
<link rel="stylesheet" href="fader/jquery.mobile-1.0a3.css" />
<script type="text/javascript" src="fader/jquery-1.5.js"></script>
<script type="text/javascript" src="fader/jquery.mobile-1.0a3.js"></script>
<script>
$('#slider-1').changed(function () {
alert("Test");
});
</script>
<style type="text/css">
.toolbar {
-webkit-box-sizing: border-box;
border-bottom: 1px solid #000;
padding: 10px;
height: 45px;
background: url(fader/Resources/Themes/JQT/img/toolbar.png) #000000 repeat-x;
position: relative;
}
.toolbar > h1 {
position: absolute;
overflow: hidden;
left: 50%;
top: 10px;
line-height: 1em;
margin: 1px 0 0 -75px;
height: 40px;
font-size: 20px; …Run Code Online (Sandbox Code Playgroud) 我试图通过AJAX将所有表单数据发送到脚本,方法是将click函数绑定到submit按钮,将其设置为false,这样它就不会提交表单了.一旦AJAX成功完成,我想通过以下方式提交表单:$("#myform").submit();但没有任何反应.
一切都有效,除了 $("#customOrderForm").submit();
这是Paypal付款.表格数据存储在会话中,用户进行支付,一旦成功付款就返回网站,表格数据通过电子邮件发送给客户和公司.
$("#submit").click(function () {
var thedata = $("#customOrderForm").serialize();
$.ajax({
type: 'POST',
url: 'buy-custom-session.php',
cache: false,
data: thedata,
beforeSend: function () {
$('#sessionholder').append('<div class="loading"><img src="loading.gif" alt="loading..." /></div>');
},
success: function (data) {
//$(".loading").detach();
//$(".error").detach();
//$('#sessionholder').append(data);
$("#customOrderForm").submit();
},
error: function () {
$('#sessionholder').append('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
HTML表格
<form id="customOrderForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- form fields etc -->
<input type="image" name="submit" id="submit" src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
Firebug中没有错误.
AJAX成功执行. …
我已经将PayPal商家帐户集成到网站上,为客户做这件事.人们可以在订阅后注册网站,因此通过PayPal付款.我们有定期付款.但是,如果人们取消订阅该网站,他们对该网站的访问权限已经关闭,但我的问题是,如果人们没有点击网站上的取消订阅,只是取消他们自己的PayPal帐户的定期付款,我将如何取消他们在网站上的订阅.请建议一些PHP代码或想法取消订阅.
在此先感谢vikas tyagi
这是我的行动网址,我希望获得16.
http://localhost/carsdirectory/Galleries/add/16
Run Code Online (Sandbox Code Playgroud)
请帮我.
我试图将一个可拖动的对象添加到一个简单的html页面.
IE给出:对象不支持此属性或方法
FF给出:jQuery(".dragthis").draggable不是一个函数
使用最新的jquery解压缩.这是代码:
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function () {
jQuery(".dragthis").draggable();
jQuery(".drophere").droppable();
});
</script>
<style>
.dragthis {
}
.drophere {
}
</style>
</head>
<body>
<div class="dragthis">dragthis</div>
<div class="drophere">drophere</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我写了一个jQuery字符计数器,它在我键入时起作用,但在粘贴文本时不起作用.该功能在粘贴时执行,但计数不会改变.我不确定val()函数是否正确或是否与DOM同步.有任何想法吗?
counter = function () {
$j("strong#status-field-char-counter").text($j("#Panel1messagesmessage").val().length);
alert('event');
};
$j("textarea").keyup(counter);
$j("textarea").bind('paste', counter);
$j("#Panel1messagesmessage").bind('copy', counter);
$j("#Panel1messagesmessage").bind('delete', counter);
Run Code Online (Sandbox Code Playgroud) 我有两个页面,我使用swipeleft和swiperight事件(来回)链接,但当我滑到另一页时,jquery不会触发pageinit事件,我只剩下页眉和页脚.我应该使用changePage事件还是应该使用loadPage事件?我知道jquerymobile的另一个版本中有一个错误,其中pageinit事件没有触发,但我已经使用已经解决它的RC1但事件仍然没有触发.什么阻止它开火?提前致谢.
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>esports</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<link rel="stylesheet" href="jquery.zrssfeed.css" />
</script>
<style>
</style>
</head>
<body>
<!-- index -->
<div data-role="page" id="index">
<div data-role="header">
<h1>esports times</h1>
</div>
<!--/header-->
<div data-role="content" id="content">
<div id="currentFeed">teamliquid. skgamin</div>
<ul id="rssFeed" data-role="listview">
</ul>
</div>
</div>
</body>
</html>
<!-- load javscripts here-->
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"> </script>
<script src="jquery.zrssfeed.js"></script>
<script>
$('#index').bind("pageinit", (function () {
$('#rssFeed').rssfeed('http://feeds.reuters.com/reuters/oddlyEnoughNews', {
limit: 10, …Run Code Online (Sandbox Code Playgroud) 用户表

在注册时间内,每个用户都必须放置parent_id,在parent_id下注册谁,所以我为它做了不同的表
赞助表
在那之后做那样的树

我想算上那样的记录

所以PLZ指导我怎么能算这样的记录,或者有任何方式我想说这种计数我必须在数据库中更改,谢谢提前
我有这样的邻接列表模式结构,我想根据级别计算父级的所有标题 Food = (2,4,3), Fruit = (3,3)
树表结构

在那之后做那样的树

通过这个代码我得到正确的总和像食物= 9,水果= 6
function display_children($parent, $level)
{
$result = mysql_query('SELECT title FROM tree '.'WHERE parent="'.$parent.'"');
$count = 0;
while ($row = mysql_fetch_array($result))
{
$data= str_repeat(' ',$level).$row['title']."\n";
echo $data;
$count += 1 + $this->display_children($row['title'], $level+1);
}
return $count;
}
Run Code Online (Sandbox Code Playgroud)
通话功能
display_children(Food, 0)
Run Code Online (Sandbox Code Playgroud)
结果:9 //但我希望得到像2,4,3的结果
但我希望得到的数据总结果如同食物2,4,3和水果3,3等级
所以PLZ指导如何获得总水平