0

Is it possible to send data on button click via ajax and use value on form on same page?

I have several button each of which will have a data attribute with a different value, I need that value to be sent/used within a form that I have

UPDATE: I have added an answer below as well as mentioning it is possibly a duplicate.

Connor Brough
  • 579
  • 1
  • 9
  • 24
  • 1
    Please show some code to help people understand the details. – Yogi May 28 '15 at 08:19
  • You can use jQuery to acquire the information from the form fields you need, but without seeing your code (both HTML and jQuery) we can't really give you more information. – Geoff Atkins May 28 '15 at 08:20
  • Yes it is entirely possible, however to be of any valuable help we need to see your current HTML and JS code, and to know exactly what result you're trying to achieve. – Rory McCrossan May 28 '15 at 08:21
  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn't meet your needs. This demonstrates that you've taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! Also see [how to ask](http://stackoverflow.com/questions/how-to-ask) – Cerbrus May 28 '15 at 08:25
  • possible duplicate of [Uploading both data and files in one form using Ajax?](http://stackoverflow.com/questions/10899384/uploading-both-data-and-files-in-one-form-using-ajax) – Mirko Cianfarani May 28 '15 at 09:55

1 Answers1

0

Apologies for the duplicate question, this gave me the answer

here is my code Stackoverflow

  <script type="text/javascript">
    $(document).ready(function(){
    $(".red").click(function(){
        var resourceID = $(this).attr("data-value"); 
         $(".iphorm-hidden input").val(resourceID);
      });
   });
  </script>
Community
  • 1
  • 1
Connor Brough
  • 579
  • 1
  • 9
  • 24