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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745279201a4620197.html
评论列表(0条)