简体   繁体   English

将eval和span id从gridview传递到javascript函数

[英]Pass eval and span id from gridview to javascript function

I'm trying to pass a value and span id to a JavaScript function. 我正在尝试将值和id传递给JavaScript函数。 I think I have the value set right but I'm having problems passing the span. 我认为我已正确设置了值,但在跨度时遇到了问题。 This is a nested gridview so I can't see the control and need to send it to the function. 这是一个嵌套的gridview,所以我看不到控件,需要将其发送给函数。

In GridView 在GridView中

 <input type="button" onclick='<%# Eval("FormulaTiming", "countdown({0}); Eval("TimeMinutes.ClientID")%>' value="Start" id="Start" />
 <input type="button" value="Stop" id="Stop" />
 <input type="text" value='<%#Eval("FormulaTiming")%>' id="TimeMinutes" />
 <span id="CountDown"></span>

JavaScript Function JavaScript功能

var interval;

  function countdown(minutes, spanid) {
      interval = setInterval(function () {
          var lbl = document.getElementById(element);
          if (seconds == 0) {
              if (minutes == 0) {
                  el.innerHTML = "countdown's over!";
                  clearInterval(interval);
                  return;
              } else {
                  minutes--;
                  seconds = 60;
              }
          }
          if (minutes > 0) {
              var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute');
          } else {
              var minute_text = '';
          }
          var second_text = seconds > 1 ? 'seconds' : 'second';
          el.innerHTML = minute_text + ' ' + seconds + ' ' + second_text + ' remaining';
          seconds--;
      }, 1000);
  }

I am still trying to figure out how to change the script, but first I need to pass the eval and span. 我仍在尝试找出如何更改脚本,但是首先我需要传递评估和跨度。

Thanks for your help 谢谢你的帮助

The following asp.net code 下面的asp.net代码

<input type="button" onclick='<%# Eval("FormulaTiming", "countdown({0}, \"Start\"); %>' value="Start" id="Start" />

Should yield the following HTML 应该产生以下HTML

<input type="button" onclick='countdown(20, "Start");' value="Start" id="Start" />

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

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