【问题标题】:Pass js parameter value in database using php使用php在数据库中传递js参数值
【发布时间】:2016-04-06 11:20:13
【问题描述】:
<input class="stars" type="radio" id="star5" onclick="myFunction('Overall rating:',5)" name="rating" value="5" />
<label class = "full" for="star5" title="Awesome - 5 stars"></label>
<input class="stars" type="radio" id="star4" onclick="myFunction('Overall rating:',4)" name="rating" value="4" />
<label class = "full" for="star4" title="Pretty good - 4 stars"></label>
<input class="stars" type="radio" id="star3" onclick="myFunction('Overall rating:',3)" name="rating" value="3" />
<label class = "full" for="star3" title="Meh - 3 stars"></label>
<input class="stars" type="radio" id="star2" onclick="myFunction('Overall rating:',2)" name="rating" value="2" />
<label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
<input class="stars" type="radio" id="star1" onclick="myFunction('Overall rating:',1)" name="rating" value="1" />
<label class = "full" for="star1" title="Sucks big time - 1 star"></label>
<font  size="4"color="#ffffff">Overall rating:</font>

如何使用php在数据库中传递js参数值?

【问题讨论】:

  • 我什么都不懂,你想要什么?
  • 您能向我们展示您为使其正常工作所做的努力吗?
  • 我有一个 html 代码,我在其中创建一个 onclick 函数并传递 2 个参数并在 js 派系上获取它我需要传递这些参数值 php,这将帮助我插入数据库

标签: javascript php mysql


【解决方案1】:

单选按钮的Onchange() 调用一个ajax 函数,它将您的响应存储在数据库中。

【讨论】:

    【解决方案2】:

    通过使用 ajax

    function myFunction(yourString, value) {
        $.get('updatePage.php', { 'yourkeyString': yourString, 'yourValue': value }, function (d) { alert('Hello from PHP: ' + d); });
    }
    

    也可以检查这个答案 https://stackoverflow.com/a/712378/6124249

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-08-27
      • 2015-05-05
      • 1970-01-01
      • 1970-01-01
      • 2018-07-25
      相关资源
      最近更新 更多