输入值改变一段时间然后消失

问题描述

我正在尝试在 wordpress 中制作一个两步式预订表格。在第一步中,用户选择行程和人数。它也可以在第二步的文本输入中看到。我需要做的是根据这些值显示新输入的人均价格和总价格。所以我用javascript写了它。它在 JSfiddle 中运行良好,但在网站上,价格值可能只闪烁一秒钟,然后消失。你能帮我吗?

谢谢

<h4>STEP 2/2</h4>
<p><input type="text" class="grey" id="tour" value="Bratislava Traditional Food Tour" disabled></p>
<p><input type="text" class="grey" id="pers" value="8 persons" disabled></label></p>
<p><label> NAME<br />
    <span class="wpcf7-form-control-wrap name-1"><input type="text" name="name-1" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false" /></span> </label></p>
<p><label> EMAIL<br />
    <span class="wpcf7-form-control-wrap email-256"><input type="email" name="email-256" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false" /></span></label></p>
<p><label> PHONE<br />
    <span class="wpcf7-form-control-wrap tel"><input type="text" name="tel" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-phonetext wpcf7-validates-as-required" id="tel" aria-required="true" aria-invalid="false" /></span></label></p>
<p><label> DO YOU PREFER A PRIVATE TOUR?<br />
    <span class="wpcf7-form-control-wrap menu-242"><select name="menu-242" class="wpcf7-form-control wpcf7-select wpcf7-validates-as-required" aria-required="true" aria-invalid="false"><option value="Select answer">Select answer</option><option value="Yes">Yes</option><option value="No">No</option></select></span></label></p>
<p><label> HOW DID YOU HEAR ABOUT US?<br />
    <span class="wpcf7-form-control-wrap menu-243"><select name="menu-243" class="wpcf7-form-control wpcf7-select wpcf7-validates-as-required" aria-required="true" aria-invalid="false"><option value="Select answer">Select answer</option><option value="Google search">Google search</option><option value="TripAdvisor">TripAdvisor</option><option value="Friend/Word of mouth">Friend/Word of mouth</option><option value="Flyer">Flyer</option><option value="Other">Other</option></select></span></label></p>
<p><label> PRICE PER PERSON<br />
<span class="wpcf7-form-control-wrap text-208"><input type="text" name="text-208" value="" size="40" class="wpcf7-form-control wpcf7-text" id="result" readonly="readonly" aria-invalid="false" /></span></label></p>
<p><label> TOTAL PRICE<br />
<span class="wpcf7-form-control-wrap text-944"><input type="text" name="text-944" value="" size="40" class="wpcf7-form-control wpcf7-text" id="total" readonly="readonly" aria-invalid="false" /></span></label></p>
<p>By clicking SUBMIT you agree to <a href="../gdpr/" target="_blank">our privacy policy terms of service</a>.</p>
<p style="text-align: right"><input type="button" value="&lt; Back" class="wpcf7-form-control wpcf7-prevIoUs" /> <input type="submit" value="Submit" class="wpcf7-form-control wpcf7-submit" /></p>
jQuery(document).ready(function(){

const source = document.getElementById("pers");
const tour = document.getElementById("tour");
const innertextoutput = document.getElementById("result");
const innertextoutput2 = document.getElementById("total");
if(tour.value == "(Nearly) All of Bratislava in 6 hours" && pers.value == "1 person") {
    result.value = "€260/person";
    total.value = "€260";
  }
  else if(tour.value == "(Nearly) All of Bratislava in 6 hours" && pers.value == "2 persons") {
    result.value = "€130/person";
    total.value = "€260";
  }

etc.

https://jsfiddle.net/b7ofc6u2/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...