submit a value from span field

后端 未结 3 1991
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 15:50

i have a from with a submit button

after using jquery the page will have :

for(var i=0 ; i <10 ; i++){
    \'\         


        
相关标签:
3条回答
  • 2021-01-16 16:02

    Something like that

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

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

    Update

    $("form").submit(function() {
         var currentConcept = $('.currentConcept').html();   // it's an Array
         var currentRelation = $('.currentRelation').html(); // it's an Array
    
       $.ajax({
         url     : // your URL,
         data    : 'currentConcept=' + currentConcept '&currentRelation=' + currentRelation,
         success : function( html ) {
                 // write your code here
                  }
    });
    

    }

    // server side (php)
    $currentConcept  = $_GET('currentConcept');
    $currentRelation = $_GET('currentRelation');
    
    0 讨论(0)
  • 2021-01-16 16:09

    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:

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

    Get these values on server side:

    print_r( $_POST );
    
    0 讨论(0)
  • 2021-01-16 16:17

    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();
    
    0 讨论(0)
提交回复
热议问题