我有一个部分有效的表格。我添加了 jquery 星级插件和一个附加字段(订阅),但它们都没有发布到下一页。我已将名称和 id 用于“评级”单选按钮,两者都不起作用。所有其他领域工作正常。
<html>
<head>
<title>
</title>
<link type="text/css" rel="stylesheet" href="/css/jquery.rating.css" />
<style type="text/css">
#capcha div {
float: left;
}
.label {
width:100px;
float: left;/*Or however much space you need for the form’s labels*/
}
.error {
color: red;
}
.row {
margin-bottom: 5px;
clear:both;
}
#subscribe {
font-size: small;
color: gray;
}
</style>
<script src="/js/s3Capcha.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/jquery.rating.pack.js"></script>
<script type="text/javascript" src="/js/jquery.MetaData.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#capcha').s3Capcha();
$('.star').rating({
required: 'hide',
});
var id = $("#id").val(),
rating = $("#rating").val(),
name = $("#name").val(),
citystate = $("#citystate").val(),
email = $("#email").val(),
message = $("#message").val(),
subscribe = $("#subscribe").val(),
s3capcha = $('#capcha input:radio:checked').val();
var nameVal = $("#name").val();
if (nameVal == '') {
$("#name_error").html('');
$("#name").after('<label class="error" id="name_error">Please enter your name.</label>');
return false
}
else
{
$("#name_error").html('');
}
/// email validation
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal = $("#email").val();
if (emailaddressVal == '') {
$("#email_error").html('');
$("#email").after('<label class="error" id="email_error">Please enter your email address.</label>');
return false
}
else if (!emailReg.test(emailaddressVal)) {
$("#email_error").html('');
$("#email").after('<label class="error" id="email_error">Enter a valid email address.</label>');
return false
}
else
{
$("#response").html('');
}
jQuery.post("/s3verify.php",
{
id: id,
rating: rating,
name: name,
citystate: citystate,
email: email,
message: message,
subscribe: subscribe,
s3capcha: s3capcha
},
function(data) {
if (data === 'Fail') {
$("#capcha_error").html('');
$("#capcha").after('<div style="clear:both"></div><label class="error" id="capcha_error">Verify your pictures selection.</label>');
} else {
alert(data);
var obj = jQuery.parseJSON(data);
$("#listcomments" + obj.id).append("<div class='rentalcomments'><b>" + obj.score + "!</b> <span class='rentalcomments'>" + obj.message + "</span></div>");
$("#commentform").dialog('destroy').remove()
}
});
return false;
});
</script>
</head>
<body>
<?php
$ID = $_GET['ID'];
?>
<div style="padding:20px;autoflow:none;">
<form>
<input id="id" type="hidden" name="id" value="<?php echo $ID; ?>"/>
<fieldset>
<h3>Make your recommendation:</h3>
<div class="row">
<label class='label'>Rating</label>
<input id="rating" name="rating" type="radio" class="star" Value="1" title="Worst"/>
<input id="rating" name="rating" type="radio" class="star" Value="2" title="Bad"/>
<input id="rating" name="rating" type="radio" class="star" Value="3" title="OK" checked="checked"/>
<input id="rating" name="rating" type="radio" class="star" Value="4" title="Good"/>
<input id="rating" name="rating" type="radio" class="star" Value="5" title="Best"/>
</div>
<div class="row">
<label class='label'>Name</label>
<input id="name" name="name" size="30" type="text"/>
</div>
<div class="row">
<label class='label'>City, State</label>
<input id="citystate" name="citystate" value=""/>
</div>
<div class="row">
<label class='label'>Email</label>
<input id="email" name="email" size="30" type="email"/>
</div>
<div class="row">
<label class='label'>Comments</label>
<textarea id="message" name="message"></textarea>
</div>
<div class="row">
<label class='label'>Subscribe</label>
<input id="subscribe" name="subscribe" type="checkbox" value="1" checked />
<span>receive updates on comments made by you.</span>
</div>
<div id="capcha"> <?php include("s3Capcha.php"); ?> </div>
<div style="clear:both"></div>
<h3> Submit the form</h3>
<input type="button" id="button" value="submit"><br>
<label id="response"></label>
</fieldset>
</form>
</div>
</body>
</html>