我有一个多页形式,能够在某些区域为用户动态添加输入,以便投入更多的工作,教育,等等。
我有两个问题:
问题1
首先,我不认为我以正确的方式获取数组值,即使我认为我有那部分工作因为我可以在屏幕上打印
问题2
每当我尝试将我回显的值推送到屏幕时,所有打印到.csv文件的内容都是Array
PHP:
$unitLevelPosition = $_POST["unitLevelPosition"];
$oectaUnit = $_POST["oectaUnit"];
$unitPresident = $_POST["unitPresident"];
$csvData = var_dump($unitLevelPosition) . "," . var_dump($oectaUnit) . "," . var_dump($unitPresident);
$fp = fopen("formData.csv", "a");
if($fp)
{
fwrite($fp, $csvData . "\n");
fclose($fp);
}
JS:
var i = 0;
function addUnitInvolvement()
{
i++;
var unitInvolvementDiv = document.createElement("div");
unitInvolvementDiv.innerHTML = '<input type="text" class="four-lines" name="unitLevelPosition[]" placeholder="Position/Committee"> <input type="text" class="four-lines" name="oectaUnit[]" placeholder="Unit"> <input type="text" class="four-lines" name="unitPresident[]" placeholder="Unit President"> <input type="date" class="four-lines" name="unitYear[]"> <input type="button" value="-" onclick="removeUnitInvolvement(this)">';
document.getElementById("unitLevelInvolvement").appendChild(unitInvolvementDiv);
}
function removeUnitInvolvement(unitInvolvementDiv)
{
document.getElementById("unitLevelInvolvement").removeChild(unitInvolvementDiv.parentNode);
};
HTML:
<form method="post" class="scholarshipForm">
<!-- start of page 3 content begins -->
<div id="page3-content">
<p class="subtitleDirection">List offices held or committees you have been involved with a the Unit level. Please include the name of the Unit President at the time of your involvement.</p>
<div class="clearFix"></div>
<div class="input-group" id="unit-level-involvement">
<label id="unitInvolvement">Unit Involvement *</label>
<div id="unitLevelInvolvement">
<input type="text" class="two-lines-textbox" name="unitLevelPosition[]" id="unitLevelPosition_1" placeholder="Position/Committee" onBlur="this.placeholder='Position/Committee'" onFocus="this.placeholder=''" onKeyUp="checkPage3()" />
<input type="text" class="two-lines-textbox" name="oectaUnit[]" id="oectaUnit_1" placeholder="Unit" onBlur="this.placeholder='Unit'" onFocus="this.placeholder=''" onKeyUp="checkPage3()" />
<div class="clearFix"></div>
<input type="text" class="two-lines-textbox" name="unitPresident[]" id="unitPresident_1" placeholder="Unit President" onBlur="this.placeholder='Unit President'" onFocus="this.placeholder=''" onKeyUp="checkPage3()" />
<input type="date" class="two-lines-textbox" name="unitYear[]" id="unitYear_1" onKeyUp="checkPage3()" />
<input type="button" value="+" onClick="addUnitInvolvement()" />
</div>
</div><!-- end of unit-level-involvement div-->
<button type="button" id="nextButton-page-3" disabled="disabled" onClick="nextPage()">Next</button>
<button type="button" id="backButton-page-3" onClick="previousPage()">Back</button>
</div><!--end of page3 content -->
<!-- page 3 content ends -->
<input type="submit" id="finalSubmit" disabled="disabled" />
</div><!--end of page 6 content -->
<div class="clearFix"></div>
</form><!--endForm-->