admin管理员组文章数量:1417653
I am trying to confirm with the user if the following string he or she is about to enter is correct but the confirmation box won't appear. Here is that segment of the code:
<html xmlns="" xmlns="">
<head>
<script>
function validateForm(){
var pkey = document.forms["createProductForm"]["pagekeyTF"].value;
var agree = confirm("Is this your product?\n\n ${pkey}");
if(agree) //Do something
else //Do something else
}
</script>
</head>
<body>
<form name="createProductForm" controller="actions" action="ImplementNewProduct" onsubmit="return validateForm()" method="post">
<g:textField id="productTF" name="productTF" value="My Product" />
<button id="createProductID" name="createButton" value="Create Product">Create Product</button>
</form>
</body>
</html>
Am I not allowed to pass in string variables in the confirmation function? Because if I take off the ${pkey}
it works fine but it does not include the user's input and that is not what I am not trying to achieve. Any help? Thanks!
I am trying to confirm with the user if the following string he or she is about to enter is correct but the confirmation box won't appear. Here is that segment of the code:
<html xmlns="http://www.w3/1999/html" xmlns="http://www.w3/1999/html">
<head>
<script>
function validateForm(){
var pkey = document.forms["createProductForm"]["pagekeyTF"].value;
var agree = confirm("Is this your product?\n\n ${pkey}");
if(agree) //Do something
else //Do something else
}
</script>
</head>
<body>
<form name="createProductForm" controller="actions" action="ImplementNewProduct" onsubmit="return validateForm()" method="post">
<g:textField id="productTF" name="productTF" value="My Product" />
<button id="createProductID" name="createButton" value="Create Product">Create Product</button>
</form>
</body>
</html>
Am I not allowed to pass in string variables in the confirmation function? Because if I take off the ${pkey}
it works fine but it does not include the user's input and that is not what I am not trying to achieve. Any help? Thanks!
-
clearly I could of also put
var agree = confirm("Is this your product?\n\n" + pkey);
If you guys aren't familiar with gstrings from groovy. – Eli Davila Commented Aug 1, 2013 at 23:26 -
Oh and I put
value="My Product"
inside the textfield for testing purposes so that way I can always get a value back. – Eli Davila Commented Aug 1, 2013 at 23:28 - 1 You need to check the error console of the browser (Ctrl+Shift+J) to see if any js error occurred. Also check the rendered html (right click, view sourcE). – mshsayem Commented Aug 2, 2013 at 0:36
- 2 Why don't people google before they ask ? – zzlalani Commented Aug 2, 2013 at 6:06
1 Answer
Reset to default 2Edit it like this :
var pkey = document.forms["createPixelForm"]["pagekeyTF"].value;
var agree = confirm("Is this your product?\n\n " + pkey);
本文标签: How do you put a string variable in the confirm() function in JavascriptHTMLStack Overflow
版权声明:本文标题:How do you put a string variable in the confirm() function in JavascriptHTML? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745279200a2651342.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论