Is it possible to submit a form even though the user is not interacting with the input box?

Viewed 23

I have a simple form and would like to submit the form but for some reason the form fails and simply refreshes the page. I am using ajax.

<ul>
<li> 1 </li>
<li> 2 </li>
</ul>

When the user clicks on the li element - the number is then displayed in the inbox using:

$(".input1").val(e.target.innerhtml); 
$(".input1").removeAttr("readonly");

(A) But when I click submit the form does not submit.

(B) However, if I manually click on the input box and insert the number 2. The form submits just fine.

I created a web app and i do not want the keyboard to appear. Instead I use css to display a scrolling list of numbers for the user to click/select from.

1 Answers

I think what you're looking for is good old <select> with <options> tags. As you can read on the MDN (linked in both tags above), <select> can be a child / descendant of the <form> element. Reading chosen values from this is also fairly easy - everything is described in the 1st link, along with HTML, CSS & JS snippets.

Or try looking for something that covers <select> with jQuery - e.g. How do you select a particular option in a SELECT element in jQuery?

Related