【问题标题】:Document Not Writing InnerHTML to DIV [closed]文档未将 InnerHTML 写入 DIV [关闭]
【发布时间】:2013-10-11 22:34:36
【问题描述】:

更新我已经更正了错误。除了一些拼写错误外,还有一些不明显的语法错误。我想出了如何使用 Firefox 的 Firebug 来发现其余部分。

感谢所有花时间阅读我的新帖子的人。

在我的代码方面需要一些帮助。我有另一个版本,问题较少,效果很好。我似乎找不到这个坏的地方。我遇到的问题是在输入/更改表单字段后 DIV 中没有显示任何内容。重置按钮工作正常。也感谢任何有关脚本软件的建议。

谢谢,

Strutte2

        <script type="text/javascript">
            function processForm() {
                var customer_Name = document.configInfo.customername.value;
                var order_Number = document.configInfo.ordernumber.value;
                var base_Model = document.configInfo.basemodel.value;
                var install_Country = document.configInfo.basemodel.value;
                var install_State = document.configInfo.installstate.value;
                var pump_Type = document.configInfo.pumptype.value;
                var Style = document.configInfo.style.value;
                var Blender = document.configInfo.blender.value;
                var specify_Side = document.configInfo.specifyside.value;
                var grades_Products = document.configInfo.gradesproducts.value;
                var hoses_Nozzles = document.configInfo.hosesnozzles.value;
                var payment_Interface = document.configInfo.paymentinterface.value;
                var meter_Type = document.configInfo.metertype.value;
                var fuel_Combinations = document.configInfo.fuelcombinations.value;
                var fuel_Inlet1 = document.configInfo.fuelinlet1.value;
                var fuel_Inlet2 = document.configInfo.fuelinlet2.value;
                var fuel_Inlet3 = document.configInfo.fuelinlet3.value;
                var vapor_Recovery = document.configInfo.vaporrecovery.value;
                var remote_Filter = document.configInfo.remotefilter.value;
                var hydrosorb_Strainer = document.configInfo.hydrosorbstrainer.value;
                var junction_Box = document.configInfo.junctionbox.value;
                var hose_Handling = document.configInfo.hoseretraction.value;
                var nozzle_Activation = document.configInfo.nozzleactivation.value;
                var Hoses = document.configInfo.hoses.value;
                var Nozzles = document.configInfo.nozzles.value;
                var payment_Platform = document.configInfo.paymentplatform.value;
                var Display = document.configInfo.display.value;
                var soft_Keys = document.configInfo.softkeys.value;
                var ethernet_Options = document.configInfo.ethernetoptions.value;
                var payment_Keypad = document.configInfo.ethernetoptions.value;
                var card_Reader = document.configInfo.cardreader.value;
                var sales_Volume = document.configInfo.salesvolume.value;
                var unit_Price = document.configInfo.pricedisplay.value;
                var preset_Keypad = document.configInfo.presetkeypad.value;
                var stop_Button = document.configInfo.stopbutton.value;
                var Totalizers = document.configInfo.totalizers.value;
                var Intercom = document.configInfo.intercom.value;
                var lock_Options = document.configInfo.lockoptions.value;
                var security_Switches = document.configInfo.securityswitches.value;
                var dallas_Reader = document.configInfo.dallasreader.value; 
                var Valance = document.configInfo.valance.value;
                var custom_Panel = document.configInfo.custompanel.value;   
`               var Packaging = document.configInfo.packaging.value;
                var graphics_Spec = document.configInfo.graphicsspec.value;
                var product_Ids = document.configInfo.productids.value;
                var Language = document.configInfo.language.value;
                var auto_Discount = document.configInfo.autodiscount.value;
                var keypad_Assembly = document.configInfo.keypadassembly.value;
                var model_String = document.configInfo.modelstring.value;
                var CSR = document.configInfo.csr.value;
                var phone_Ext = document.configInfo.phoneext.value; 


                var holdInfo =  '<div> Customer Name: ' + customer_Name + '</div>' +
                            '<div> Order Number:' + order_Number + '</div>' +
                        '<div> Base Model: ' + base_Model + '</div>' + 
                        '<div> Installation Country ' + install_Country + '</div>' + 
                        '<div> Installation State ' + install_State + '</div>' + 
                        '<div> Pump Type:' + pump_Type + '</div>' + 
                        '<div> Style: ' + Style+ '</div>' +
                        '<div> Blender: ' + Blender+ '</div>' +
                        '<div> Specify Side: ' + specify_Side+ '</div>' +
                        '<div> No. Grades/Products: ' + grades_Products+ '</div>' +
                        '<div> No. Hoses/Nozzles: ' + hoses_Nozzles+ '</div>' +
                        '<div> Payment Interface: ' + payment_Interface+ '</div>' +
                        '<div> Meter Type: ' + meter_Type+ '</div>' +
                        '<div> Fuel Combinations: ' + fuel_Combinations+ '</div>' +
                        '<div> Fuel Inlet 1: ' + fuel_Inlet1+ '</div>' +
                        '<div> Fuel Inlet 2: ' + fuel_Inlet2+ '</div>' +
                        '<div> Fuel Inlet 3: ' + fuel_Inlet3+ '</div>' +
                        '<div> Vapor Recovery: ' + vapor_Recovery+ '</div>' +
                        '<div> Remote Filter: ' + remote_Filter+ '</div>' +
                        '<div> Hydrosorb Strainer: ' + hydrosorb_Strainer+ '</div>' +
                        '<div> Junction Box: ' + junction_Box+ '</div>' +
                        '<div> Hose Handling: ' + hose_Handling+ '</div>' +
                        '<div> Nozzle Activation: ' + nozzle_Activation+ '</div>' +
                        '<div> Hoses: ' + Hoses+ '</div>' +
                        '<div> Nozzles: ' + Nozzles+ '</div>' +
                        '<div> Payment Platform: ' + payment_Platform+ '</div>' +
                        '<div> Display: ' + Display+ '</div>' +
                        '<div> Soft Keys: ' + soft_Keys+ '</div>' +
                        '<div> Ethernet Options: ' + ethernet_Options+ '</div>' +
                        '<div> Payment Keypad: ' + payment_Keypad+ '</div>' +
                        '<div> Card Reader: ' + card_Reader+ '</div>' +
                        '<div> Sales Volume: ' + sales_Volume+ '</div>' +
                        '<div> Unit Price Display: ' + unit_Price+ '</div>' +
                        '<div> Preset Keypad: ' + preset_Keypad+ '</div>' +
                        '<div> Stop Button:  ' + stop_Button+ '</div>' +
                        '<div> Totalizers: ' + Totalizers+ '</div>' +
                        '<div> Intercom:  ' + Intercom+ '</div>' +
                        '<div> Lock Options: ' + lock_Options+ '</div>' +
                        '<div> Security Switches: ' + security_Switches+ '</div>' +
                        '<div> IDS (Dallas) Reader: ' + dallas_Reader+ '</div>' +
                        '<div> Valance: ' + Valance+ '</div>' +
                        '<div> Extra Custom Panel: ' + custom_Panel+ '</div>' +
                        '<div> Packaging: ' + Packaging+ '</div>' +
                        '<div> Graphics Spec & #: ' + graphics_Spec+ '</div>' +
                        '<div> Product IDs: ' + product_Ids+ '</div>' +
                        '<div> Language: ' + Language+ '</div>' +
                        '<div> Automatic Discount: ' + auto_Discount+ '</div>' +
                        '<div> Keypad Assembly: ' + keypad_Assembly+ '</div>' +
                        '<div> Model String: ' + model_String + '</div>' +
                        '<div> CSR: ' + CSR + '</div>' +
                        '<div> Phone Ext: ' + phone_Ext + '</div>';

                    document.getElementById("copyfield").innerHTML = holdInfo;  

                        }

            function clearForm() {
                var blank = "";
                document.getElementById('copyfield').innerHTML = blank;
            }


        </script>

JSLint 在定义错误方面没有多大帮助。

【问题讨论】:

  • 如果是 javascript 问题,为什么还要添加额外的 css 和 html
  • 到底是什么坏了?当你做什么时,什么不会发生?请详细说明问题所在以及如何重现问题。您是否在浏览器错误控制台中查看过脚本错误?
  • 对,那是很多代码。如果您需要帮助(而不是很多 'tl;dr' 后跟 '去别的地方'),您需要将其减少到重现问题所需的 最少 代码。
  • 在浏览器的开发工具打开的情况下运行它。这有多个拼写错误和无效名称,您的开发工具控制台会告诉您其中的每一个。
  • validator.w3.org 显示您的页面有 132 个错误和 6 个警告。

标签: javascript dom innerhtml


【解决方案1】:

这一行看起来像是一个错字(configINfo 的拼写错误):

var install_State = document.configINfo.installstate.value;

浏览器中的错误控制台应该会显示发生脚本错误的确切行。很可能还有其他错误。

【讨论】:

  • +1 用于挖掘垃圾以找到问题。我认为这将是一个错字
  • 感谢您的帮助!我真的很感激。
【解决方案2】:

有不止一个拼写错误

改变:

var install_State = document.configINfo.installstate.value;

到:

var install_State = document.configInfo.installstate.value;

改变:

var hose_Handling = document.configInfo.hosehandling.value;

到:

var hose_Handling = document.configInfo.hoseretraction.value;

改变:

var unit_Price = document.configInfo.unitprice.value;

到:

var unit_Price = document.configInfo.pricedisplay.value;

【讨论】:

  • 谢谢,你用什么工具调试?
  • PhpStorm 这是一个非常好的 PHP IDE 并且便宜:)
猜你喜欢
  • 2014-06-07
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 1970-01-01
  • 1970-01-01
  • 2020-04-03
  • 2018-02-08
  • 1970-01-01
相关资源
最近更新 更多