简体   繁体   English

使用下一个和上一个按钮循环浏览不同的DIV

[英]Cycle through different DIVs using Next and previous buttons

I found this code online and its exactly what i need apart from, i need it to have finish button that will submit a form but i cannot manage to get it working 我在网上找到了此代码,除了我真正需要的之外,我还需要它具有完成按钮才能提交表格,但我无法使其正常运行

Put some code here.

jsFiddle jsFiddle

Any ideas you can give me? 有什么想法可以给我吗?

This script just cycle through a couple divs. 该脚本仅循环几个div。
But you can use the "c" variable to set a value of an hidden form input. 但是您可以使用“ c”变量来设置隐藏表单输入的值。
Put your form under the end of <div class="innerContent"> 将表格放在<div class="innerContent">

<form action='YourTargetPage.php' method='post'>
<input type='hidden' value='3' id='selectedDiv'>
<input type='submit' value='submit'>
</form>

And add this to the loadContent() jQuery script: 并将其添加到loadContent()jQuery脚本中:

$('#selectedDiv').val(c);


You will then have a $_POST['selectedDiv'] containing the 'c' value in yourTargetPage.php. 然后,在yourTargetPage.php中将有一个$ _POST ['selectedDiv']包含'c'值。

The c variable is zero based since it's the index of an array... So 0=project 1, 1=Project 2, ect. c变量基于零,因为它是数组的索引。所以0 = project 1,1 = Project 2,依此类推。

The default (onload) value of the hidden input should be the same as the default value of the script var c = 3; 隐藏输入的默认(加载)值应与脚本的默认值var c = 3; in case the user select the first project without triggering the loadContent() function. 如果用户选择第一个项目而不触发loadContent()函数。
;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM