0
What is wrong?
function dpad(){ var a = document.createElement("input"); a.type = "number"; document.getElementsByTagName("body")[0].appendChild(a); a.click(); } window.onload = dpad; EDIT: EVERYTHING WORKS BUT I NEED TO FORCE A CLICK TO THE INPUT
17 Respuestas
+ 2
Check this:
https://www.w3schools.com/jsref/met_html_click.asp
you need either:
a.setAttribute("onclick", "action()"); // set the attribute
or
a.addEventListener("click", action); // create an event listener
before simulating a click.
perhaps what u want to do is focus();
a.focus(); // It'll go to the input box ready for u to type the number
try focus instead of a.click(); and check the result.
I'm a newbie too, so pardon me if I can't explain correctly.
+ 2
It shows a number input as I run the code. Actually, I don't get what you mean by "make a number dpad"; are you talking about dial pad? like phone number? in that case, I guess you need an input with "tel" as 'type' attribute.
+ 1
https://code.sololearn.com/WBDpsgBkRODA/?ref=app
The pad pops up when u use tablet smartphone, in PC no need cuz u have the keyboard.
+ 1
Not sure what your intention is here, but dpad is a function and needs to be called as such. At the moment, you are simply assigning it to window.onload, but its not being invoked.
0
What is the problem? What were you expecting from that code, provide more info please ...
0
U want a number pad like a calculator?
0
Jorat Nope.
0
I give up i tried my best hahahaha
0
I tried to search how to force keyboard popup on mobile, but couldn't find a viable solution, unfortunately.
0
Answer:
[0].appendChild(a);
Wrong
- 1
Ipang it does nothing. It is suppost to make a number dpad.
- 1
Jorat it still does not work.
- 1
I guess my device just doesn't support it.
- 1
I want the number pad from type=number, but i can not get it to automatically pop up.
- 1
Abdurrahim That has nothing to do with it
- 1
PROGRAMMA No that part works i need to force the dpad to pop up.
- 1
Aaron Gillies i need to use the function name because if i use the () identifier it thinks i want it to run what dpad returns and therefor runs the code before the window loads.
Sorry for the realllly late reply