首页 \ 问答 \ 输出所选按钮值或名称(Output selected button value or name)

输出所选按钮值或名称(Output selected button value or name)

我正在尝试从按钮中获取值并在窗口中输出已选择的内容,因为我说数组未定义

请帮助纠正我的错误。

<input type="radio" name="flavor" id="vanilla" value="Vanilla" checked="checked" />Vanilla 
<input type="radio" name="flavor" id="choc" value="Chocolate" />Chocolate
<input type="radio" name="flavor" id="strawberry" value="Strawberry" />Strawberry

var flavorArray = ["","","Vanilla","Chocolate","Strawberry"];

var flavorValue = document.querySelector('input[name = "flavor"]:checked').value;

flavorArray[flavorvalue]  -<< my output 

I'm trying to get values from the button and output in the window what has been selected, for me says array is undefined.

Please help correct my mistake.

<input type="radio" name="flavor" id="vanilla" value="Vanilla" checked="checked" />Vanilla 
<input type="radio" name="flavor" id="choc" value="Chocolate" />Chocolate
<input type="radio" name="flavor" id="strawberry" value="Strawberry" />Strawberry

var flavorArray = ["","","Vanilla","Chocolate","Strawberry"];

var flavorValue = document.querySelector('input[name = "flavor"]:checked').value;

flavorArray[flavorvalue]  -<< my output 

原文:https://stackoverflow.com/questions/40478841
更新时间:2023-01-21 19:01

最满意答案

对此有几个部分答案。

  1. Windows构建是通过Linux机器上的MinGW交叉编译器完成的。

  2. 由于(至少)0.9.2,不再需要使用MinGW在Windows机器上构建Thrift编译器。 1)除了事实,你根本不需要这样做,因为下载页面上有预编译的EXE,有一个很好的Visual Studio项目来构建Windows Thrift编译器EXE。 该项目只有两个依赖项:Bison和Lexx / Yacc,它们也可以在其他地方作为预编译设置使用。

  3. 在任何一种情况下,MinGW仅用于构建编译器。 如果你想用MinGW构建库,我不确定它是否有效。 这种做事方式没有得到实施或支持,仅仅因为没有人需要它。

这让我们回到了这个问题,为什么你认为你“需要”这种方式。


1) 据我所知,autotools存在许多严重的问题,以及在Windows机器上在MinGW下构建Thrift所需的所有东西。 您将需要修补内容,从源代码构建一些内容,花费大量时间并使用文件系统执行一些奇怪的操作以使其正常工作。 至少在两年前我停止使用MinGW来制造Thrift的情况就是如此。 即使你让它工作,你仍然只能得到编译器(你可以在很短的时间内轻松下载),而不是库。


There are several partial answers to this.

  1. The Windows build is made by means of MinGW cross compiler on a Linux machine.

  2. Since (at least) 0.9.2 it is no longer necessary to use MinGW to build the Thrift compiler on a Windows machine.1) Aside from the fact, that you don't need to do that at all, because a precompiled EXE is available on the download pages, there is a nice Visual Studio project to build the Windows Thrift compiler EXE. The project has only two dependencies: Bison and Lexx/Yacc, which are both available elsewhere as precompiled Setups as well.

  3. In either case MinGW is only used to build the compiler. If you want to build the libraries with MinGW, I'm not sure if that even works. This way of doing things is not implemented or supported, simply because nobody needs it.

Which brings us back to the question, why you think you "need" it this way.


1)To my knowledge, numerous severe problems exist with the autotools and all the stuff needed to build Thrift under MinGW on a Windows machine. You will have to patch things, build some from source, spend a lot of time and do some strange things with your file system to make it work. At least that was the case when I stopped using MinGW to build Thrift about two years ago. And even if you get it to work, you still only get the compiler (which you could easily download in a fraction of that time), not the libraries.

相关问答

更多
  • 我从官方网站下载页面下载了0.8.0 gz的节俭版本,并自行创建了jar文件(jar cf thrift-0.8.0.jar src / org) 你为什么要创建自己的罐子? 为什么你使用源文件创建它? jar库必须至少包含字节码类,可以使用。 你必须让节俭编译成一个jar然后使用它: 浏览到/lib/java 在终端运行ant 检查构建文件夹,你会看到一个.jar 使用那个 I've downloaded 0.8.0 gz version of thrift from the official websi ...
  • 我有了工作的想法。 我们必须避免所有GetTimeOfDay ,并从项目文件GetTimeOfDay.cpp, GetTimeOfDay.h删除并使用的函数gettimeofday 。 如果有人会得到同样的错误,我可以提供更多代码。 而且,当然,如果你能找到更好的方法来解决这个问题(或者说,这个问题在Thrift的更多版本中得到了解决) - 随意发布在这里! :) I got working idea. We must avoid all GetTimeOfDay, and delete f ...
  • 问题的可能原因是端口10000已在使用中(如您的注释中提到的Hiveserver已在运行,默认情况下使用端口10000)。 运行thrift服务器时可以更改它(例如10005)。 我建议您启动thrift服务器,如下所示: $cd $SPARK_HOME $./sbin/start-thriftserver.sh --hiveconf hive.server2.thrift.port=10005 --master yarn-client 请参阅此处的文档 Possible cause of the pr ...
  • 如果在Windows中使用EXE安装程序,则不需要Cygwin。 EXE安装程序安装Thrift.EXE。 运行时库可以在存储库分支之外使用 ,还有用于Visual Studio的构建项目。 除此之外,还有一个针对Thrift编译器本身的VS构建项目 。 那不是很好吗? PS: https : //thrift.apache.org/docs/install/windows有点过时了。 谢谢你的提醒。 If you use the EXE installer in Windows, there is no ...
  • Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory 解释我猜的一切..只需添加slf4j依赖项 Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory explains everything I guess.. Just add slf4j dependency
  • 我在Eclipse中遇到了同样的问题,以及IntelliJ。 我发现thrift编译器和lib-thrift之间的thrift版本不同步。 我有一个版本0.6.0的thrift(来自$ sudo port install thrift)我用来生成我的java代码,并使用了lib-thrift-0.8.0.jar 我按照以下说明从源代码安装Thrift,为我的平台 ,然后重新生成并更新我生成的java thrift代码并解决了这些错误。 I ran into this same issue In Eclips ...
  • IDL文件cassandra.thrift通常是cassandra包的一部分,但您可以按照上面的链接找到它。 链接指向主干,您可能需要其他版本。 在您下载了该文件的正确版本或更好地在下载的 Cassandra软件包的interface文件夹中找到该文件后,请按照您的文档中所述生成代码。 其余的应该很容易。 为什么PHP模块不像Cassandra那样为MongoDB提供? 我发现的大多数独立司机已经过时,不再受支持或被遗弃。 我对此并不确定,但我的猜测是事实上CQL现在被大量推广,而不是使用原始的Thrift ...
  • 已命名的管道运输已添加到Thrift。 从SVN获取开发代码(目前为0.8.0-dev) - 有关下载详细信息,请参阅http://thrift.apache.org/download/ 。 它应该包含在0.9.0稳定版中,假设它没有破坏任何东西。 TPipe传输现在具有* NIX和Windows的跨平台支持。 它在Windows下实现为命名或匿名管道; 在* NIX下,它通过利用TSocket来使用域套接字。 * NIX下尚不支持匿名管道。 它应该相对简单地添加,但似乎没有它的需求。 我还提供了一个示例项 ...
  • 对此有几个部分答案。 Windows构建是通过Linux机器上的MinGW交叉编译器完成的。 由于(至少)0.9.2,不再需要使用MinGW在Windows机器上构建Thrift编译器。 1)除了事实,你根本不需要这样做,因为下载页面上有预编译的EXE,有一个很好的Visual Studio项目来构建Windows Thrift编译器EXE。 该项目只有两个依赖项:Bison和Lexx / Yacc,它们也可以在其他地方作为预编译设置使用。 在任何一种情况下,MinGW仅用于构建编译器。 如果你想用MinG ...
  • 好像Thrift编译器没有思想那么好。 无法降低继承方法的可见性 表明来自抽象类或接口的继承方法最初具有更高的可见性,例如“public”,而代码中有“private”。 我会尝试将其设置为“公开”,看看会发生什么。 代码可能编译得很好,因为我期望由于编译/转换代码而在方法上缺少可见性设置而产生不匹配,因为可以编写方法头而不指定visiblitiy: void doany(){ // nothing } 该方法在这种情况下使用类可见性(主要是“公共”) - 编译器将误解。 seems like th ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)