-1

I am trying to submit a form from a JSP page to a servlet. I am trying to make a dynamic page, where a form opens up on press of a button and send the data when the form is submitted. When the form is submitted the popup form closes and returns to the main page. I have implemented the form, and the popup form closes when i click on post but the data is not sent to the servlet.

Code of form:

<div class="form-group">
  <label for="select" class="col-lg-2 control-label">Technology</label>
  <select class="form-control" id="select">
    <option>Java</option>
    <option>C++</option>
    <option>C</option>
    <option>Python</option>
    <option>.Net</option>
    <option>Javascript</option>
  </select>
  <br> <label for="select" class="col-lg-2 control-label">Query</label>
  <textarea class="form-control" rows="3" id="textArea"></textarea>
</div>
<div class="modal-footer">
  <button type="reset" class="btn btn-default"
    data-dismiss="modal">Close</button>
  <button type="submit" id="pst" class="btn btn-primary"
    data-dismiss="modal">Post</button>
</div>

I tried to go to the send to the servlet via different solutions provided over the web, but nothing seems to work. The function is being called since i tried doing an alert inside the onclick function, the alert did show but nothing else. Any Suggestions?

morels
  • 2,095
  • 17
  • 24
Shaurya Chaudhuri
  • 3,772
  • 6
  • 28
  • 58

1 Answers1

0

You know it, seems to me you are missing the name attribute on the form elements.

<select class="form-control" id="select"> <!-- no name attr-->
<textarea class="form-control" rows="3" id="textArea"></textarea><!-- no name attr-->

Whenever you submit a form name attributes serializes the form elements with it's value.

Jai
  • 74,255
  • 12
  • 74
  • 103
  • Well , I am trying to get the attributes via the id of field. Rather than actually posting it the conventional way. I dont want to redirtect to another page. – Shaurya Chaudhuri Oct 29 '15 at 13:52
  • @ShauryaChaudhuri — **start** with the [conventional way](https://en.wikipedia.org/wiki/Unobtrusive_JavaScript) and progressively enhance from there. – Quentin Oct 29 '15 at 14:05
  • Well i Did try the conventional way but that didnt work either. So i thought using jQuery might make it easier, but that didnt work out either – Shaurya Chaudhuri Oct 29 '15 at 14:43