Larry Brister
asked on
pass in string to function
Hhw would I pass in a string on button click to my script below?
<button class="button-blue" id="test1" runat="server" onclick="custom1();">Try it</button>
<script>
var custom1 = function () {
uglipop({
class: 'put', //styling class for Modal
source: 'html',
content: '<div><br /><br /><br />There seems to be a problem.<br/>' + vat + '<br /> Please verify your card information.</div>'
});
}
</script>
<!DOCTYPE html>
<html>
<head>
<title>HTML, CSS and JavaScript demo</title>
<script src="https://cdn.jsdelivr.net/npm/uglipop@1.0.0/uglipop.js"></script>
<style>
.put{
border-radius: 10px;
background-color:white;
width:300px;
height:300px;
padding:10px;
-webkit-box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
}
</style>
</head>
<body>
<!-- Start your code here -->
<p class="lw">Hello Weaver!</p>
<button class="button-blue" id="test1" onclick="custom1('This is an example string');">Try it</button>
<!-- End your code here -->
<script>
var custom1 = function(arg){
uglipop({class:'put', //styling class for Modal
source:'html',
content:'<div>'+ arg+' </div>'});}
</script>
</body>
</html>
What string do you want to pass and why?
ASKER
I actually went with setting a hidden value and reading from that
Otherwise... the popup kept opening and closing after 1 second.
Otherwise... the popup kept opening and closing after 1 second.
<script>
var ddd = document.getElementById('<%= HiddenStatusFlag.ClientID%>').value;
var custom1 = function () {
uglipop({
class: 'put', //styling class for Modal
source: 'html',
content: '<div><br /><br /><br />There seems to be a problem.' + ddd + 'Please verify your card information.</div>'
});
}
</script>
var ddd = document.getElementById('<%= HiddenStatusFlag.ClientID%>').value;
function remove(){
document.getElementById('uglipop_overlay_wrapper').style.display = 'none';
document.getElementById('uglipop_overlay').style.display = 'none';
document.getElementById('uglipop_content_fixed').style.display = 'none';
}
var custom1 = function(arg){
if(ddd){
uglipop({class:'put', //styling class for Modal
source:'html',
content:'<div><br /><br /><br />There seems to be a problem. ' + ddd + ' Please verify your card information.</div>'});
}else{
uglipop({class:'put', //styling class for Modal
source:'html',
content:'<div><br /><br /><br />There seems to be a problem.' + ddd + 'Please verify your card information.</div>'});
setTimeout(function(){
remove();
}, 1000);
}
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Julian
On button click there is logic that is applied ...
Right before I call that popup I set that Hidden value
On button click there is logic that is applied ...
Right before I call that popup I set that Hidden value
Protected Sub btnClick_Click(sender As Object, e As EventArgs) Handles btnClick.Click
'blah... blah... blah... code
HiddenStatusFlag.Value = "TEST"
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "script", "$(document).ready(function () { custom1(); });", True)
End Sub
Then my solution is fine - it should work.
ASKER
Thanks
You are welcome.
Open in new window
and then pass in the string to the call:Open in new window