Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将输入更改为类似于div段落?_Javascript_Jquery_Html_Paypal - Fatal编程技术网

Javascript 如何将输入更改为类似于div段落?

Javascript 如何将输入更改为类似于div段落?,javascript,jquery,html,paypal,Javascript,Jquery,Html,Paypal,我有贝宝多个复选框的形式,非常基于输入 我将总和显示在Input中,我希望总和显示在Div中,这样我就可以用css装饰它 代码如下: <SCRIPT type=text/javascript> <!-- function Dollar (val) { // force to valid dollar amount var str,pos,rnd=0; if (val < .995) rnd = 1; // for old Netscape browsers s

我有贝宝多个复选框的形式,非常基于输入

我将总和显示在Input中,我希望总和显示在Div中,这样我就可以用css装饰它

代码如下:

<SCRIPT type=text/javascript>
<!--
function Dollar (val) {  // force to valid dollar amount
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  // float, round, escape
  pos = str.indexOf (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
}function ReadForm (obj1, tst) { // process radio and checkbox
var i,j,amt=0,des="",obj,pos,val,tok,tag,
  op1a="",op1b="",op2a="",op2b="",itmn="";
var ary = new Array ();
  if (obj1.baseamt) amt  = obj1.baseamt.value*1.0;  // base amount
  if (obj1.basedes) des  = obj1.basedes.value;  // base description
  if (obj1.baseon0) op1a = obj1.baseon0.value;  // base options
  if (obj1.baseos0) op1b = obj1.baseos0.value;
  if (obj1.baseon1) op2a = obj1.baseon1.value;
  if (obj1.baseos1) op2b = obj1.baseos1.value;
  if (obj1.baseitn) itmn = obj1.baseitn.value;
  for (i=0; i<obj1.length; i++) {  // run entire form
    obj = obj1.elements[i];        // a form element
    if (obj.type == "checkbox" ||  // checkboxes
        obj.type == "radio") {     //  and radios
      if (obj.checked) {           // did user check it?
        val = obj.value;           // the value of the selection
        ary = val.split (" ");          // break apart
        for (j=0; j<ary.length; j++) {  // look at all items
// first we do single character tokens...
          if (ary[j].length < 2) continue;
          tok = ary[j].substring (0,1); // first character
          val = ary[j].substring (1);   // get data
          if (tok == "@") amt = val * 1.0;
          if (tok == "+") amt = amt + val*1.0;
          if (tok == "%") amt = amt + (amt * val/100.0);
          if (tok == "#") {             // record item number
            if (obj1.item_number) obj1.item_number.value = val;
          ary[j] = "";                // zap this array element
          }
// Now we do 3-character tokens...
          if (ary[j].length < 4) continue;
          tok = ary[j].substring (0,3); // first 3 chars
          val = ary[j].substring (3);   // get data
          if (tok == "s1=") {           // value for shipping
            if (obj1.shipping)  obj1.shipping.value  = val;
            ary[j] = "";                // clear it out
          }
          if (tok == "s2=") {           // value for shipping2
            if (obj1.shipping2) obj1.shipping2.value = val;
            ary[j] = "";                // clear it out
          }
        }
        val = ary.join (" ");           // rebuild val with what's left        tag = obj.name.substring (obj.name.length-2);  // get flag
        if      (tag == "1a") op1a = op1a + " " + val;
        else if (tag == "1b") op1b = op1b + " " + val;
        else if (tag == "2a") op2a = op2a + " " + val;
        else if (tag == "2b") op2b = op2b + " " + val;
        else if (tag == "3i") itmn = itmn + " " + val;
        else if (des.length == 0) des = val;
        else des = des + ", " + val;
      }
    }
  }
// Now summarize stuff we just processed, above
  if (op1a.length > 0) obj1.on0.value = op1a;
  if (op1b.length > 0) obj1.os0.value = op1b;
  if (op2a.length > 0) obj1.on1.value = op2a;
  if (op2b.length > 0) obj1.os1.value = op2b;
  if (itmn.length > 0) obj1.item_number.value = itmn;
  obj1.item_name.value = des;
  obj1.amount.value = Dollar (amt);
  if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
}
//-->
</SCRIPT>
<!-- End of Script --> 

<body>

Pizza Order Form.

<br><br>

<!-- Another method for the View Cart Form - add this code anywhere within the web page -->

<!-- This is the FORM to view the cart contents -->
<!-- Note: target="paypal" was replaced with the variable target="_self" -->
<!-- Note: shopping_url also added to code -->
<!-- These two changes allow better functionality with IE and Firefox -->
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="viewcart" name="viewcart">
<!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. -->
<input type="hidden" name="cpp_header_image" value="https://www.yourwebsite.com/logo.jpg">
<p>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="display" value="1">
<!-- Replace "business" value with your PayPal Email Address or Account ID -->
<input type="hidden" name="business" value="your @ emailaddress.com">
<!-- Replace value with the web page you want the customer to return to -->
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Script_02.html">
</p>
</form>
<!-- End of the viewcart FORM -->




<!-- Start of Form -->
<!-- Note: target="paypal" was replaced with the variable target="_self" -->
<!-- Note: shopping_url also added to code -->
<!-- These two changes allow better functionality with IE and Firefox -->
<FORM onsubmit="this.target='_self';&#10; return ReadForm(this, true);" action=https://www.paypal.com/cgi-bin/webscr method=post>
<!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. -->
<input type="hidden" name="cpp_header_image" value="https://www.yourwebsite.com/logo.jpg">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<!-- Replace "business" value with your PayPal Email Address or Account ID -->
<input type="hidden" name="business" value="your @ emailaddress.com">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="amount" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn/btn_cart_LG.gif:NonHosted">
<!-- Replace value with the web page you want the customer to return to -->
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Script_02.html">
<!-- Replace value with the web page you want the customer to return to after a successful transaction -->
<input type="hidden" name="return" value="http://www.yourwebsite.com/ThankYou.html">
<!-- Replace value with the web page you want the customer to return to after item cancellation -->
<input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html">
<input type="hidden" value="0.00" name="baseamt">
<input type="hidden" value="Widget Lg Plain Pizza - @0.00" name="basedes">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">


Add Toppings
<br><br>  
<input onclick="ReadForm (this.form, false);" type=checkbox value="Pepp +1.50"> Pepperoni - Add $1.50
<br><br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="It Saug +1.50"> It Saugsage - Add $1.50
<br><br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Ons +1.10"> Onions - Add $1.10
<br><br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Mush +1.25"> Mushrooms - Add $1.25
<br><br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Gr Peppers +1.15"> Green Peppers - Add $1.15

<br><br>

<input class=nbor size=6 value=$0.00 name=tot> &nbsp; &nbsp;

<br>
<input type=image alt="cart add" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" name=submit>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">

<br><br>
<input onclick="document.forms.viewcart.target = '_self';&#10; document.forms.viewcart.submit ();&#10; return false;" type=image alt="cart view" src="https://www.paypalobjects.com/en_US/i/btn/btn_viewcart_LG.gif">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
</form>


对sum使用隐藏输入以在表单中工作,并附加具有相同内容的div以用于显示/样式设置

<input type="hidden" size="6" value="" name="tot">

<div id="totalAmount"></div>

//onform activity
$('[name=tot]').val(//total dollar amount);
$('#totalAmount').text(//'$'+total dollar amount)

//onform活动
$('[name=tot]').val(//美元总额);
$('#totalAmount')。文本(/“$”+美元总额)

评论这两行:

if (obj1.tot) obj1.tot.value = "$" + Dollar(amt);
<input class=nbor size=6 value=$0.00 name=tot>

我到底在哪里添加Javascript代码?我不知道-我没有真正阅读你的代码。我只是说解决问题的一种方法是对表单元素使用输入,对html元素使用div,这样就可以对其进行样式化。您将需要调查在何处可以实现这一点(如果有的话)。我们的想法是将div放在表单的末尾,在那里显示总计和其他隐藏输入,然后在更改fom时创建一个函数,用新的总计更新每个函数。因此,js部分将与javascript代码的其余部分一起使用。看到这一点,它只激活了颜色样式。字体系列:arial;字体大小:16px;文本阴影:4px纯黑风格?@StackBuck我认为您应该检查如何编写正确的
文本阴影属性。在这个属性中,字体系列已更改为arial。但是字体装饰如何?它们是正确的。请在
中编写CSS代码。显示金额{}
以设置所需的格式
if (obj1.tot) obj1.tot.value = "$" + Dollar(amt);
<input class=nbor size=6 value=$0.00 name=tot>
<div class="display-amount"></div>
var displayAmount = document.querySelector(".display-amount");
if (displayAmount) {
   displayAmount.firstChild.nodeValue = "$" + Dollar(amt);
}