0

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.

HottopiK
  • 3
  • 2
  • 2
    It would be more helpful if you could provide the related html code so we can reproduce this – Carsten Løvbo Andersen Sep 20 '22 at 06:27
  • 1
    Hi, welcome to SO. Please do take the time to read the [tour] and [ask]. In this case, your question would also benefit from a snippet that demonstrates the issue - include only the minimum code needed to demonstrate/reproduce the issue. See [mcve]. – freedomn-m Sep 20 '22 at 07:53

1 Answers1

-1

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?

  • Thanks Gawron - That worked like a charm and to everyone else - my bad for not providing enough detail in the snippet. – HottopiK Oct 14 '22 at 05:52