如何使用输入来影响javascript变量? (Html文件) [英] How do I use an input to effect javascript variable? (Html file)

查看:60
本文介绍了如何使用输入来影响javascript变量? (Html文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



这是我目前的代码:

 <  !DOCTYPE     html  >  

< head >
< title > 流测试< / title >
< / head >

< html >
< ; <跨度class =code-leadattribute> body style = background-color:black >
< script src = http://player.twitch.tv/js/embed/v1。 js > < / script >
< div align = center id = {PLAYER_DIV_ID} > < / div < span class =code-keyword>>
< script type = text / javascript >
var options = {
宽度: 1600
身高: 900
频道: {channelnamehere}
/ / 视频:{VIDEO_ID}
};
var player = new Twitch.Player( {PLAYER_DIV_ID},options);
player.setVolume( 0 5 );
< / script >
< / html >





我想知道我怎么能得到一个输入框可以将频道变量更改为用户输入的任何内容,并且能够连续更改它。



提前感谢



我尝试过的事情:



我不确定如何解决这个问题,所以很遗憾我还没有尝试过多,因为我在HTML中有一个平庸的水平。

解决方案

要获得文本框中的值,这很容易。



  var  value =  document  .getElementById(  txtSomeId)。value; 


Hello,

This is the code I currently have:

<!DOCTYPE html>

<head>
	<title>Stream Test</title>
</head>

<html>
	<body style="background-color: black">
		<script src= "http://player.twitch.tv/js/embed/v1.js"></script>
		<div align="center" id="{PLAYER_DIV_ID}"></div>
		<script type="text/javascript">
			var options = {
				width: 1600,
				height: 900,
				channel: "{channelnamehere}",
				//video: "{VIDEO_ID}"
			};
			var player = new Twitch.Player("{PLAYER_DIV_ID}", options);
			player.setVolume(0.5);
		</script>
</html>



and I was wondering how I could get an input box that would change the "channel" variable to whatever the user inputs with the ability to continuously change it.

Thanks in advance

What I have tried:

I'm rather unsure how I would go about this, so unfortunately I haven't tried much yet as I have a mediocre level in HTML.

解决方案

To get the value in a textbox it is very easy.

var value = document.getElementById("txtSomeId").value;


这篇关于如何使用输入来影响javascript变量? (Html文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆