Shikhar Srivastava February 2016

How to post form value with span tag in php?

I have a form in which there are many span elements and every span element have their id's my span tag is working as a input text field for form now I want to send the span field value to my php file to insert in my db like in php $_POST['fname'] this value we can get if we are using input type text but if it is a span how to do this?

My code is:

<form action="form_submit1" method="POST">
   <div class="form-group">
        <span class= "sexyform" id="6" name="fname" data-placeholder="Enter Your First Name"></span>
        </div>
</form>

Answers


paranoid February 2016

You use ajax

$(document).on("click", ".sexyform", function () {
   var id=$(this).attr('id');
   $.ajax({
    type: 'POST',
    url: "form_submit1",
    data:{fname:id},
    success: function (result) {
       your action after success
     },
  })
})

Post Status

Asked in February 2016
Viewed 1,839 times
Voted 8
Answered 1 times

Search




Leave an answer