【问题标题】:I want to pass html form values to href tag on button我想将html表单值传递给按钮上的href标签
【发布时间】:2020-06-03 02:44:35
【问题描述】:

我目前在 Shopify 商店工作。

我想添加一个按钮,单击该按钮会打开一个 whatsapp 聊天,其中包含客户正在观看的产品的当前信息。

但是,产品页面上有一个由客户填写的表单,我想将这些值传递给打开聊天的链接。

这是我现在拥有的,这段代码包括液体代码和html:

<form action="https://wa.me/50258437780?text=¡Hola!%20estoy%20interesado%20en%20el%20siguiente%20mueble:%20{{product.title}}%20,%20{{current_variant.title}}">
  <label for="fname">Código tela:</label><br>
  <input type="text" id="tela" value="" name="fname"><br>
  <label for="lname">Código Acabado:</label><br>
  <input type="text" id="acabado" name="fname"><br>
  <a class="button" href="https://wa.me/50258437780?text=¡Hola!%20estoy%20interesado%20en%20el%20siguiente%20mueble:%20{{product.title}}%20,%20{{current_variant.title}}+document.getElementById('tela').value">COTIZAR</a> <br>
</form>

【问题讨论】:

  • 控制台有错误吗?单击按钮时,您可以尝试添加一个函数并向其传递参数。比调用 window.location (w3schools.com/js/js_window_location.asp) 重定向到 whatsapp 聊天

标签: javascript html shopify liquid


【解决方案1】:

我使用 javascript 来解决它,通过 ID 捕获元素,然后使用 concat() 附加它们,我还将链接值分配给一个变量以连接它

【讨论】:

    猜你喜欢
    • 2012-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2023-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多