2013-05-30 40 views
0

張貼我有部分工作的形式。我添加了jquery star rating插件和一個附加字段(訂閱),並且他們都沒有發佈到下一頁。我已經使用名稱和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-\.][email protected]([\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> 
+0

您遇到了什麼問題?我剛剛測試了代碼,並收到了所有參數 – isJustMe

+0

我沒有收到評分或訂閱數據。 – user2332467

回答

0

這裏的問題: 。等級=( 「#rating」)val應爲....等級= $( '輸入:無線​​電[名稱=等級]:勾選')。VAL(),

1

你需要指定形式的行動 - 到頁面將數據發送到

<form action='next page url' method='POST'> 

而且按鈕使用 -

<input type="submit" value="Submit"> 

可能幫助!

編輯:

變化these-

<input name="rating" type="radio" class="star" Value="1" title="Worst"/> 
    <input name="rating" type="radio" class="star" Value="2" title="Bad"/> 
    <input name="rating" type="radio" class="star" Value="3" title="OK" checked="checked"/> 
    <input name="rating" type="radio" class="star" Value="4" title="Good"/> 
    <input name="rating" type="radio" class="star" Value="5" title="Best"/> 

和jQuery的 -

rating = $(".star:checked").val() 

或 -

rating = $('input[type=radio]:checked').val() 
+0

我更新了我的代碼以顯示處理按鈕上的點擊操作的JavaScript。這個頁面是彈出窗口,它從源頁面獲得一些javascript。 – user2332467

+0

你沒有得到什麼? – Razor

+0

我發現訂閱的問題。我在JavaScript中拼寫錯了。現在只有評級片沒有提供數據。 – user2332467