+ 1
I basically want to create a custom confirm box in js that return true and false value
Let value = customconfirmbox(' are you sure'); If(value){}else{} Function customconfirmbox(msg){ //if user click on ok button then return true //else return false Doc.getelbyid('box').innerhtml = msg; //plz dont mind for dom written in short } //html <div> <div> Msg </div> <button>ok</button> <button>cancel</button> </div>
10 Answers
0
You can use event listeners
0
Rupali any example : ?
Var variable should even wait till the function returns any value
And function will return value when user click something
0
if (document.getElementById('button').clicked === true){
Call function
...
...
}
else {
do something else
...
...
}
0
Rupali actually event listener also didn't helped me, plz have a look at my code
https://code.sololearn.com/Wklv65MI55mG/?ref=app
0
check this, is that way you wanted ??
https://code.sololearn.com/WvmX7Y7uZW4d/?ref=app
0
NonStop CODING actually no
The alert box directly comes after i click on call but i want it should come after i click button of box (ok button or cancel button)
0
oooh so you mean whenever you hit ok alert 1
hit cancel alert 0
then set event listeners on ok and cancel
and whenever you hit call
make the box visible
0
is that way
make sure you explain your question clearly to us?
https://code.sololearn.com/WvmX7Y7uZW4d/?ref=app
0
NonStop CODING but i want it tu return me true/false value and the var should have that value returned by the function
- 1
show your attempts first. đ€đ€
You chose to write
// plz dont mind for dom written in short instead of ( 48 characters including spaces )
doc.getElementById('box').innerHTML = msg; ( 42 characters )
formal one is longer than the latter. Come on dude what were you thinking đđđ