简体   繁体   English

将标签的innerhtml传递给PHP中的变量

[英]Passing innerhtml of a label to a variable in PHP

I want to pass the inner html of a label in HTML form to a variable in PHP via POST method.我想通过 POST 方法将 HTML 形式的标签的内部 html 传递给 PHP 中的变量。 but I don't know how to do so.但我不知道该怎么做。 Here is my code .这是我的代码。

    <select id="ops" name="select" onChange="myfunction(this)">

                    <option>PIck item </option>
                    <option value="pepsi">pepsi</option>
                    <option value="coke">coke</option>
                    <option value="fanta">Fanta</option>

    </select><br><br>


<label id="lb" style="display:none" >Qty</label>

<input type="text" name='qtytext' id="num" style="display:none" placeholder="Quantity" onKeyUp="return validateform()"  onSelect="return validateform()" onFocus="myfun2()" required/ >


<label id="lb2" style="display:none" name='price' >  </label>

I want to pass the innerHTML of the above Label to a variable in PHP.我想将上述Label的innerHTML传递给PHP中的一个变量。 InnerHtml has been already set by JS . JS 已经设置了 InnerHtml 。

When updating innerHTML of label, put the value in a hidden form input.更新标签的innerHTML时,将值放入隐藏表单输入中。 And, finally post the form to the server.并且,最后将表单发布到服务器。

If you set the label via JS, you should set the value of another input field in the form simultaneously:如果你通过JS设置标签,你应该同时设置表单中另一个输入字段的值:

<form>
  <input type="hidden" name="labelContent" value="theValueToSet" />
</form>

考虑使用表单或 AJAX 发布值并通过var_dump( $_POST );在您的操作页面上获取这些值var_dump( $_POST );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM