2013-05-22 57 views
0

如何在表單提交後設置文本框的值?如何在表單提交後設置文本框的值?

IM使用這個js塊,但仍即時有麻煩中的文本框或DIV存儲一個值

<script type="text/javascript"> 

(function($,W,D) 
{ 
    var JQUERY4U = {}; 

    JQUERY4U.UTIL = 
    { 
     setupFormValidation: function() 
     { 
      //form validation rules 
      $("#register-form").validate({ 
       rules: { 
        wsndate: "required", 
        wsndescription: "required", 
        wsncrs: "required"}, 
       messages: { 
        wsndate: "Please enter your wsndate", 
        wsndescription: "Please enter your description", 
        wsncrs: "Please enter a CRS"  
       }, 
       submitHandler: function(form) { 

        //form.submit(); 


        //retrieving form values 
        var wsnString = ""; 
        _wsnDate = document.getElementById("wsndate").value; 
        _wsndescription = document.getElementById("wsndescription").value; 
        _wsnCRS = $('select[name="' + $('select[name="dropdownmain"]').val() + '"]').val() 


        //Computation for Page update (simple) 
        _pageupdate_simple = document.getElementById("pageupdate_simple").value; 
        if(document.getElementById("pageupdate_simple_urgent").checked) 
        { 
         //Page update simple URGENT! 
         var _pageupdate_simple_unit_price = 30; 
        } 
         else 
        { 
         //Page update simple Normal 
         var _pageupdate_simple_unit_price = 15; 
        } 
        _pageupdate_simple_cost = _pageupdate_simple * _pageupdate_simple_unit_price; 


        //Computation for Page update (complex) 
        _pageupdate_complex = document.getElementById("pageupdate_complex").value; 
        if(document.getElementById("pageupdate_complex_urgent").checked) 
        { 
         //Page update complex URGENT! 
         var _pageupdate_complex_unit_price = 50; 
        } 
         else 
        { 
         //Page update complex Normal 
         var _pageupdate_complex_unit_price = 25; 
        } 
        _pageupdate_complex_cost = _pageupdate_complex * _pageupdate_complex_unit_price;  

        //Computation for PDF update/upload 
        _pdfUpdate = document.getElementById("pdfUpdate").value; 

        var _pdfUpdate_unit_price = 15; 
        var _succeeding_pdf = 7.5; 
        var _pdfNumbers; 
        var _subSequent; 
        var _pdfUpdateCost; 

        if(_pdfUpdate > 1) 
        { 
         _subSequent = _pdfUpdate -1; 
         var _subSequentCost; 
         _subSequentCost = _subSequent * _succeeding_pdf; 
         _pdfUpdateCost = _pdfUpdate_unit_price + _subSequentCost; 
        } 
        else if(_pdfUpdate == 0) 
        { 
         _pdfUpdateCost = 0; 
        } 
        else 
        { 
         _pdfUpdateCost = _pdfUpdate_unit_price; 
        } 

        //Computation for Add/update promo box 
        _promoboxUpdate = document.getElementById("promoboxUpdate").value; 

        var _promoboxUpdate_unit_price = 15; 
        var _succeeding_promobox = 7.5; 
        var _promoboxNumber; 
        var _subSequentPromobox; 
        var _promoboxUpdateCost; 

        if(_promoboxUpdate > 1) 
        { 
         _subSequentPromobox = _promoboxUpdate -1; 
         var _subSequentPromoboxCost; 
         _subSequentPromoboxCost = _subSequentPromobox * _succeeding_promobox; 
         _promoboxUpdateCost = _promoboxUpdate_unit_price + _subSequentPromoboxCost; 
        } 
        else if(_promoboxUpdate == 0) 
        { 
         _promoboxUpdateCost = 0; 
        } 
        else 
        { 
         _promoboxUpdateCost = _promoboxUpdate_unit_price; 
        } 


        //Computation for Page Creation 
        _pageCreation = document.getElementById("pageCreation").value; 
        if(document.getElementById("pageCreation_urgent").checked) 
        { 
         //Page creation URGENT! 
         var _pageCreation_unit_price = 100; 
        } 
         else 
        { 
         //Page creation Normal 
         var _pageCreation_unit_price = 50; 
        } 
        _pageCreation_cost = _pageCreation * _pageCreation_unit_price; 

        //append the values for the costs 
        var _wsnCost = _pageupdate_simple_cost + _pageupdate_complex_cost + _pdfUpdateCost + _promoboxUpdateCost + _pageCreation_cost; 



        wsnString = _wsnDate+'_'+_wsndescription+'_'+_wsnCRS+'_$'+_wsnCost; 
        //Session["wsnvalues"] = wsnString; 
        //window.location.href = 'page2.html'; 

        alert(wsnString); 


        //window.location.href = 'page2.html'; 
       } 
      }); 
     } 
    } 

    //when the dom has loaded setup form validation rules 
    $(D).ready(function($) { 
     JQUERY4U.UTIL.setupFormValidation(); 
    }); 

})(jQuery, window, document); 
</script> 

我想wsnString的值設置爲一個文本框或DIV其中i可以複製所生成的文本。這可能嗎?

回答

0
$('#mytextbox').val(wsnString). 
相關問題