Dhtmlx message => prompt

Hello,

Currently I use this code to ask a user for his age or some other input.

var age=""; age = prompt ("What is your age?","");

It would be awesome if I could use the dhtmlx-layout. I only don’t know how to do it. Is it possible or not (yet)? Can I use dhtmlx message for it?

Thank you in advance.

Hi

you can use dhtmlxMessage. you also can use window + layout + form.
please attach mockup of awaited design and I will suggest you the best way.

I want it to be a popup like dhtmlxmessage.

I photoshoped what I want, see below. Can you give me the code how to achieve that?
(The user can enter some text in the field below the question.)

Hi

  1. open dhtmlxmessage.js and modify modal_key function:

function modal_key(e){ if (_dhx_msg_cfg){ e = e||event; if ((e.target||elsrcElement).className == "dhtmlx_popup_input") return true; var code = e.which||event.keyCode; if (dhtmlx.message.keyboard){ if (code == 13 || code == 32) callback(_dhx_msg_cfg, true); if (code == 27) callback(_dhx_msg_cfg, false); } if (e.preventDefault) e.preventDefault(); return !(e.cancelBubble = true); } }

  1. add the following common function

function askAge(callback) { var t = document.createElement("DIV"); t.innerHTML = "<div>What is your age?</div>"+ "<div><input type='text' value='' class='dhtmlx_popup_input'></div>"; var id = "dhxmsgId_"+new Date().getTime(); dhtmlx.confirm("<div id='"+id+"'></div>", function(r){ if (r == true) r = t.lastChild.firstChild.value; callback(r); t = null; }); document.getElementById(id).appendChild(t); }

  1. call in your code and check the result

askAge(function(age){ if (age === false) { console.log("cancel pressed"); } else { console.log(age); } });

also you can contact our sales dept at sales@dhtmlx.com and request official modification.