0
我想知道,如果有人可以幫助我,我在下面的代碼無法顯示新的領域,如果有人能幫助或指導,我將不勝感激顯示新的字段不會出現
<!-- // another fields here //-->
<div id="new_field"--></div>
<script type="text/javascript">
var inputs = {
fields: 0,
target: "new_field",
addInput: function() {
if (this.fields != 5) {
this.fields++;
var newElement = document.createElement('div');
newElement.id = this.target + this.fields;
newElement.innerHTML = "<?php if ($emails) { foreach ($emails as $result) { ?><b><?php echo $entry_emails; ?></b><br /><input type='text' name='emails[]' value='<?php echo $result; ?>' size='auto' maxlength='100%' /><?php } } ?>";
document.getElementById(this.target).appendChild(newElement);
} else {
alert("Only 5 fields allowed.");
}
},
};</script>
或許它不會出現,因爲PHP代碼
newElement.innerHTML = "<?php if ($emails) { foreach ($emails as $result) { ?><b><?php echo $entry_emails; ?></b><br /><input type='text' name='emails[]' value='<?php echo $result; ?' size='auto' maxlength='100%' /><?php } } ?>";
當時我使用此代碼工作正常,當先前
<table id="add_friends">
<!-- // another fields here //-->
<tr>
<td><b><?php echo $entry_email; ?></b></td>
<td>
</td>
</tr>
<?php if ($emails) { foreach ($emails as $result) { ?>
<tr>
<td><b><?php echo $entry_emails; ?></b></td>
<td><input type="text" name="emails[]" value="<?php echo $result; ?>" /></td>
</tr>
<?php } } ?>
</table>
<script type="text/javascript">
function addFriend() {
var tbl = document.getElementById('add_friends');
var iteration = tbl.tBodies[0].rows.length;
newRow = tbl.tBodies[0].insertRow(-1);
var newCell = newRow.insertCell(0);
newCell.innerHTML = 'Entry Your friend email';
var newCell1 = newRow.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'emails[]';
el.size = 30;
el.maxlength = 45;
newCell1.appendChild(el);
}</script>
或者是否有可能將代碼更改爲底層代碼?還是有更好的意見?
嗨,謝謝你,但有沒有可能使用PHP的頂級代碼?你能讓我看看它是如何工作的嗎? – user485783 2011-01-23 19:31:26