php - submit a value from span field


i have a from with a submit button

after using jquery the page will have :

for(var i=0 ; i <10 ; i++){
  '<span >'+ currentConcept[i] +'</span>\n\
         <span >'+ currentRelation[i] +'</span>\n\'

(that piece of code is just an example)

the variables currentConcept[] and currentRelation[] i got its values from database using Ajax

**i am using PHP**

and my question how to submit the page with these two variables ?

i mean in the server i hope something to be like this

 $concepts = $_POST['currentConcept[]']



Get these values in jQuery like this:

var ioAddConcept = $(".ioAddConcept").html();
var ioAddRelation = $(".ioAddRelation").html();

Now you can set these values into form text boxes:

$('input.ioAddConcept').text( ioAddConcept );
$('input.ioAddRelation').text( ioAddRelation );

OR if you are submit form via AJAX request:

        url     : '/path/to/action.php',
        type    : 'POST',
        data    : 'value1=' + ioAddConcept '&value2=' + ioAddRelation,
        success : function( data ) {

Get these values on server side:

print_r( $_POST );



Add an ID to your span element

<span id="ElementID"> your variable text here</span>

Then use jquery to get the text out

var spanText = $('#ElementID').html();



Something like that

var currentConcept = $('currentConcept').html();

And then you can send this var as a param in you request to server


$("form").submit(function() {
     var currentConcept = $('.currentConcept').html();   // it's an Array
     var currentRelation = $('.currentRelation').html(); // it's an Array

     url     : // your URL,
     data    : 'currentConcept=' + currentConcept '&currentRelation=' + currentRelation,
     success : function( html ) {
             // write your code here


// server side (php)
$currentConcept  = $_GET('currentConcept');
$currentRelation = $_GET('currentRelation');

People are also looking for solutions to the problem: php - symfony2 doctrine with 2 bundles


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.