Can the value of a form element be boolean? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:12:51
Original
1472 people have browsed it

For example, in the following code

<form name="myform>    <input name="para1" type="hidden" value="false" /></form>
Copy after login


I found that the value false of para here is a string. Is there any way to turn this value into a Boolean value?


Reply to discussion (solution)

var x = document.getElementsByName('para1')[0].value;x = (x === 'false' ? false : true);alert(x);
Copy after login

JScript code
var x = document.getElementsByName('para1 ')[0].value;
x = (x === 'false' ? false : true);
alert(x);

Thank you T5500, I have tried this method , the result proves that even if a Boolean value false is assigned to It is troublesome to define another variable and use if statement to judge. I don’t know if there is any other way

The attribute values ​​of DOM are all strings.

Convert it according to your own needs


The attribute values ​​of DOM are all strings.

Convert it according to your needs


That’s it, thank you~

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template