+ 4

[SOLVED] How can I move cursor?

I'd like to make the checkbox interactive so when someone check it, the cursor jumps into the input box. Thanks for the answers. https://code.sololearn.com/WRc9VLM9oQNg

15th Dec 2021, 2:35 PM
Tsunugi
Tsunugi - avatar
18 Réponses
+ 15
<input type="checkbox" name="checkbox" onclick="if(this.checked) text.focus();" /> This sets the cursor on the text input
15th Dec 2021, 2:59 PM
Ipang
+ 3
And what should happen when the checkbox is unchecked?
15th Dec 2021, 2:45 PM
Ipang
+ 3
Tsunugi Set focus on input if checkbox is checked
15th Dec 2021, 2:47 PM
A͢J
A͢J - avatar
+ 3
You're welcome Tsunugi, BTW I can't reply DMs, so just post it here if you have another query ...
15th Dec 2021, 3:26 PM
Ipang
+ 3
How many pairs of checkbox & text though? this will require use of Javascript in any ways ...
15th Dec 2021, 3:30 PM
Ipang
+ 2
Ipang nothing actually. I want making it an "other option" in a list and I'd like the cursor would jump to the text box so people can write what is their "other" opinion.
15th Dec 2021, 2:47 PM
Tsunugi
Tsunugi - avatar
+ 2
Ipang thank you! I'll go and try out. I had a bit hard time with focus
15th Dec 2021, 3:01 PM
Tsunugi
Tsunugi - avatar
+ 2
Ipang thank you so much! This worked instantly just like I wanted! Thanks again 👍👍👍
15th Dec 2021, 3:05 PM
Tsunugi
Tsunugi - avatar
+ 2
Solution: <input type="checkbox" name="checkbox" onclick="if(this.checked){ document.getElementById('textbox ID').focus();}/> if you have more than one textboxes.
15th Dec 2021, 3:54 PM
Tsunugi
Tsunugi - avatar
+ 2
Tsunugi 👍
15th Dec 2021, 4:03 PM
Ipang
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ thanks! I give it a try. Still newbie here~
15th Dec 2021, 2:48 PM
Tsunugi
Tsunugi - avatar
+ 1
Ipang thanks again... How do you define the text.focus if you have more than one text box?
15th Dec 2021, 3:27 PM
Tsunugi
Tsunugi - avatar
0
Ipang There's two text boxes and a textarea(if that's matter..)
15th Dec 2021, 3:31 PM
Tsunugi
Tsunugi - avatar
0
Heyy
17th Dec 2021, 2:18 PM
satyam awasthi
satyam awasthi - avatar
0
satyam awasthi Not a right place to say hi hello
17th Dec 2021, 2:21 PM
A͢J
A͢J - avatar
0
I know right.
17th Dec 2021, 2:23 PM
Prajwal Pai
Prajwal Pai - avatar
- 1
Click the right button.
22nd Dec 2021, 12:35 PM
satyam awasthi
satyam awasthi - avatar
- 4
Move your mouse?
16th Dec 2021, 5:59 PM
Prajwal Pai
Prajwal Pai - avatar