简体   繁体   English

我如何在不同的php页面上显示范围滑块的实时值?

[英]How Can i echo the real time value of range slider on different php page?

I have a paper slider in my index.php page. 我的index.php页面中有一个纸张滑块。 I am able to get the real time value of paper slider and display its value in input type=text... of form ,textarea... and div. 我能够获取纸张滑块的实时值,并在输入type = text ...形式,textarea ...和div中显示其值。

What i want is to echo the real time of values of this slider in another php page.for eg: value.php Is there any way I can do it? 我想要的是在另一个PHP page.for中响应此滑块的实时值,例如:value.php有什么办法可以做到?

I will be very grateful. 我将非常感谢。

Here is my Code: 这是我的代码:

 <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <title>paper-input</title> <script src="https://www.polymer-project.org/0.5/components/webcomponentsjs/webcomponents.js"></script> <link href="https://www.polymer-project.org/0.5/components/paper-slider/paper-slider.html" rel="import"> <link href="https://www.polymer-project.org/0.5/components/font-roboto/roboto.html" rel="import"> <link rel="stylesheet" href="css/foundation.css"> <script src="js/vendor/modernizr.js"></script> <style shim-shadowdom> body{ font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial; margin: 0; padding: 24px; } paper-slider { width: 100%; } section { max-width: 1000px; padding: 20px 0; background-color: #f0f0f0; } section > div { padding: 14px; } .yellow-slider paper-slider::shadow #sliderKnobInner, .yellow-slider paper-slider::shadow #sliderBar::shadow #activeProgress { background-color: #f4b400; } .green-slider paper-slider::shadow #sliderKnobInner, .green-slider paper-slider::shadow #sliderKnobInner::before, .green-slider paper-slider::shadow #sliderBar::shadow #activeProgress { background-color: #0f9d58; } #ratingsLabel { padding-left: 12px; color: #a0a0a0; } </style> </head> <body> <div id="valueslide"></div> <form role="form" method="POST"> <textarea id="mytextarea" name="slider">Text to be changed</textarea> </form> <table> <!--tr specifies a new row--> <tr> <td>Value</td> <td><input type=text id='firstNumber' value=''></td> </tr> </table> <template is="auto-binding"> <paper-slider on-immediate-value-change="{{sliderChange}}" min="0" max='100' pin immediateValue="{{sliderValue}}"></paper-slider> </template> </body> <script> document.querySelector('template').addEventListener('template-bound', function() { this.sliderChange = function() { var x=(this.sliderValue); var n = x.toString(); document.getElementById("valueslide").innerHTML=x; document.getElementById('mytextarea').innerHTML =x; document.getElementById('firstNumber').value =n; }; }); </script> </html> 

There are a few different options here. 这里有一些不同的选择。

  1. AJAX : you would publish by AJAX any changes to your server when the change event is fired. AJAX :触发​​更改事件时,您将通过AJAX将对服务器的所有更改发布。 You could store the value in a DB or some other data store. 您可以将值存储在数据库或其他数据存储中。 The subscriber page would then poll for changes to that data store and retrieve the new value (again by AJAX). 然后,订阅者页面将轮询该数据存储区的更改并检索新值(再次由AJAX进行)。
    Pros : Easy to implement 优点 :易于实施
    Cons : you'd be constant opening and closing connections and you'd need to manage the order of responses carefully. 缺点 :您将不断打开和关闭连接,并且需要仔细管理响应顺序。
  2. Web Sockets : you would open a web socket to the server and publish changes, the subscriber would also have a web socket connection open, so the server would pass the value on. Web套接字 :您将打开服务器的Web套接字并发布更改,订阅服务器还将打开Web套接字连接,以便服务器将值传递给服务器。
    Pros : Very fast and no need to closely manage connections 优点 :速度非常快,无需密切管理连接
    Cons : Limited browser support and PHP is not suited to the task (NodeJS is your friend here) 缺点 :浏览器支持有限,PHP不适合该任务(NodeJS是您的朋友)
  3. Firebase (other services are available): probably the ideal solution would be to use a 3rd pub/sub such as Firebase that do the hard stuff of option 2, but with the fallback of option 1. Firebase (可以使用其他服务):可能理想的解决方案是使用第3个pub / sub,例如Firebase ,它执行选项2的工作,但具有选项1的后备功能。
    Pros : takes the difficult stuff off your plate, easy to implement, fast 优点 :轻松解决难题,易于实现,快速
    Cons : 3rd party 缺点 :第三方

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

相关问题 如何在拖动 slider 时实时获取范围 slider 的值? - How to get the value of a range slider in real-time while dragging the slider? 如何实时更新滑块的值? - How do I get the value of a slider to update in real-time? 如何在不刷新页面的情况下使用javascript实时移动范围类型输入的滑块? - How to real-time move the range type input's slider using javascript without refreshing page? 如何在jQ Range滑块的标签中显示时间? - How can I show time in the label of jQ Range slider? 如何检索和显示滑块范围值? - How can I retrieve and display slider range value? 如何获取范围滑块的当前值? - How can I get current value of range slider? 如何在 2 位显示 slider 范围的值? - How can i display a value of slider range in 2 place? 提交表单时如何从滑块范围jquery中回显值,以及如何从$ _GET值设置滑块范围的值? - How to echo value from slider range jquery when submit form And How to set value of slider range from $_GET value? 如何同时输出仪表图和折线图实时数据,问题出在server.php页面? - How can I output gauge chart and line chart real-time data at the same time, problem is in server.php page? 我如何将echo的值存储到php变量中 - How I can Store value of echo into php variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM