Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从范围字段提交一个值_Php_Jquery_Html_Submit_Form Submit - Fatal编程技术网

Php 从范围字段提交一个值

Php 从范围字段提交一个值,php,jquery,html,submit,form-submit,Php,Jquery,Html,Submit,Form Submit,我有一个带有提交按钮的from 使用jquery后,页面将具有: for(var i=0 ; i <10 ; i++){ '<span class="ioAddConcept">'+ currentConcept[i] +'</span>\n\ with\n\ <span class="ioAddRelation">'+ currentRelation[i] +'</s

我有一个带有提交按钮的from

使用jquery后,页面将具有:

for(var i=0 ; i <10 ; i++){
    '<span class="ioAddConcept">'+ currentConcept[i] +'</span>\n\
                  with\n\
                  <span class="ioAddRelation">'+ currentRelation[i] +'</span>\n\'
}
我的问题是如何提交包含这两个变量的页面

我的意思是,在服务器上,我希望这样

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

向span元素添加一个ID

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

向span元素添加一个ID

<span id="ElementID"> your variable text here</span>
诸如此类

var currentConcept = $('currentConcept').html();
然后,您可以将该变量作为请求中的参数发送到服务器

更新

}

诸如此类

var currentConcept = $('currentConcept').html();
然后,您可以将该变量作为请求中的参数发送到服务器

更新

}


在jQuery中按如下方式获取这些值:

var ioAddConcept = $(".ioAddConcept").html();
var ioAddRelation = $(".ioAddRelation").html();
现在,您可以将这些值设置到表单文本框中:

$('input.ioAddConcept').text( ioAddConcept );
$('input.ioAddRelation').text( ioAddRelation );
或者,如果您要通过AJAX请求提交表单:

    $.ajax({
        url     : '/path/to/action.php',
        type    : 'POST',
        data    : 'value1=' + ioAddConcept '&value2=' + ioAddRelation,
        success : function( data ) {
                    alert(data);
                  }
    });
在服务器端获取以下值:

print_r( $_POST );

在jQuery中按如下方式获取这些值:

var ioAddConcept = $(".ioAddConcept").html();
var ioAddRelation = $(".ioAddRelation").html();
现在,您可以将这些值设置到表单文本框中:

$('input.ioAddConcept').text( ioAddConcept );
$('input.ioAddRelation').text( ioAddRelation );
或者,如果您要通过AJAX请求提交表单:

    $.ajax({
        url     : '/path/to/action.php',
        type    : 'POST',
        data    : 'value1=' + ioAddConcept '&value2=' + ioAddRelation,
        success : function( data ) {
                    alert(data);
                  }
    });
在服务器端获取以下值:

print_r( $_POST );


我不是要求在我的JS中使用这些变量的值,我是问如何将它们发送到服务器在使用它之前,您必须从元素中获取值您使用什么平台/技术提交表单?PHP、MVC3等?@LinCR你应该用这些信息更新问题,这样我们就有了所有的信息。我不是要求在我的JS中使用这些变量的值,我是问如何将它们发送到服务器。你必须先从元素中获取值,然后才能使用它。你使用什么平台/技术提交表单?PHP、MVC3等?@LinCR你应该用这些信息更新问题,这样我们就有了所有的信息1-你能给我一个例子吗,2-这些变量在一个循环中,你能告诉我如何将它发送到服务器吗?请只做一件事,我不想使用$.ajax,检查我的代码,我在哪里以及如何在我的jquery函数中使用你的代码,谢谢你,你指的是哪个Jquery函数??你可以使用另一个jqyery函数,比如jquery->$.get或$.post。我的意思是我想要的函数,看看它,第二个AJAX调用中的currentconcept和currentRelation 1-你能给我一个例子吗,2-这些变量在一个循环中,你能告诉我如何将它发送到服务器吗,检查我的代码,在哪里以及如何在我的jquery函数中使用您的代码,并感谢您指的是哪个jquery函数??你可以使用另一个jqyery函数,比如jquery->$.get或$.post。我的意思是我想要的一个函数,看看它,第二个AJAX调用中的currentconcept和currentRelation,在服务器中,我如何接收它们?我测试了你的工作,它确实可以工作,并打印这个数组[0]=>totti[1]=>totti我可以更改[0]和[1],在我上一篇评论中检查我的结果,它应该像您在jQueryAjax函数的数据选项中描述的那样。在我的示例中,它们应该是数组[value1]=>totti[value2]=>totti。请显示您的ajax函数代码。我在JSFIDLE中没有找到ajax函数?在服务器中,我如何接收它们?我测试了您的工作,它确实工作了,并打印此数组[0]=>totti[1]=>totti我可以更改[0]和[1],在我最后的注释中检查我的结果。它应该与您在jQuery ajax函数的数据选项中描述的一样。在我的示例中,它们应该是数组[value1]=>totti[value2]=>totti。请显示您的ajax函数代码。我在JSFIDLE中没有找到ajax函数?