+ 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>

15th Mar 2022, 10:55 AM
Deepak Kanojiya
Deepak Kanojiya - avatar
10 Respuestas
0
You can use event listeners
15th Mar 2022, 11:56 AM
Rupali Haldiya
Rupali Haldiya - avatar
0
Rupali any example : ? Var variable should even wait till the function returns any value And function will return value when user click something
15th Mar 2022, 11:59 AM
Deepak Kanojiya
Deepak Kanojiya - avatar
0
if (document.getElementById('button').clicked === true){ Call function ... ... } else { do something else ... ... }
15th Mar 2022, 12:05 PM
Rupali Haldiya
Rupali Haldiya - avatar
0
Rupali actually event listener also didn't helped me, plz have a look at my code https://code.sololearn.com/Wklv65MI55mG/?ref=app
15th Mar 2022, 12:51 PM
Deepak Kanojiya
Deepak Kanojiya - avatar
0
check this, is that way you wanted ?? https://code.sololearn.com/WvmX7Y7uZW4d/?ref=app
15th Mar 2022, 1:25 PM
NonStop CODING
NonStop CODING - avatar
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)
15th Mar 2022, 1:28 PM
Deepak Kanojiya
Deepak Kanojiya - avatar
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
15th Mar 2022, 1:32 PM
NonStop CODING
NonStop CODING - avatar
0
is that way make sure you explain your question clearly to us? https://code.sololearn.com/WvmX7Y7uZW4d/?ref=app
15th Mar 2022, 1:39 PM
NonStop CODING
NonStop CODING - avatar
0
NonStop CODING but i want it tu return me true/false value and the var should have that value returned by the function
15th Mar 2022, 2:00 PM
Deepak Kanojiya
Deepak Kanojiya - avatar
- 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 😁😁😁
15th Mar 2022, 11:45 AM
NonStop CODING
NonStop CODING - avatar