单击提交时,如何让我的表单运行一个函数?
<form id="commentForm" name="comment">
<fieldset>
<label for="name">Name <span>(required)</span></label>
<input type="text" class="text" id="name" value="" />
<label for="email">Email <span>(will not be published) (required)</span></label>
<input type="text" class="text" id="email" value="" />
<label for="website">Website</label>
<input type="text" class="text" id="website" value="" />
<label for="message">Message <span>(required)</span></label>
<textarea id="message" class="textarea" rows="10"></textarea>
<input type="submit" name="submit" class="submit" id="submit_btn" value="Submit Comment" action="JavaScript: ajax_add_comment();">
</fieldset>
...
Run Code Online (Sandbox Code Playgroud)
我正在尝试运行以下功能:
function ajax_add_comment () {
alert ("testing");
}
Run Code Online (Sandbox Code Playgroud) 我怎么能用逗号(,)以某种方式分割/分离我的JavaScript变量.
然后检查是否value-of-any-of-the-separated-strings = "something"
例如,我的变量有值1,2,3,4,5,6,7,8,9,10,2212312,我想检查是否有任何数字= 7在IF语句中.
有没有人有任何想法如何做到这一点?
在这段代码中,jQuery Animate边框似乎不能很好地运行:http: //jsbin.com/ewuyup/13/edit
有没有人有任何想法来解决它?
我在Animate的jQuery网站上看到了这个.
不完全支持速记CSS属性(例如字体,背景,边框).例如,如果要为渲染的边框宽度设置动画,则必须至少预先设置"auto"以外的边框样式和边框宽度.或者,如果要为字体大小设置动画,则可以使用fontSize或CSS等效的'font-size'而不是简单的'font'.
希望可以有人帮帮我.
我目前正在尝试让我的Ajax将一些信息从HTML表单发布到PHP表单中.
那么,现在我已经制作了差异代码,应该在"ajax.comment.php"页面打印出来,告诉发生了什么.
就像成功与否一样.
我现在想制作我的ajax,检查打印的html是什么.然后处理...就像if(打印HTML =="1"){然后做某事}.
我怎样才能做到这一点?
我的以下javascript是:
var name = document.comment.name.value;
var email = document.comment.email.value;
var website = document.comment.website.value;
var message = document.comment.message.value;
var id = document.comment.id.value;
$.ajax({
type: "POST",
url: "ajax.addcomment.php",
data: "name="+name+"&email="+email+"&website="+website+"&message="+message+"&id="+id,
beforeSend: function() {
// Action before sending data
},
success: function(returned_html) {
// Action after sending data, where the returned_html var is the returned html text by the php
}
});
Run Code Online (Sandbox Code Playgroud) 我一直在研究这个教程:http: //blog.new-bamboo.co.uk/2009/12/30/html5-canvas-snake-game
但我出于某种原因无法弄清楚如何让蛇每次都开始随机出现..
任何想法如何做到这一点?
嗯..我想检查网址是否有效.
所以,他们不能只输入之类的东西hoadw,adwij£1%但插入的URL必须像一个有效的domain.com.
想到这样的功能:
function checkurl($url) {
if ($url = "VALID") {
return true;
}else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)