这是我的代码,我想在用户单击添加链接按钮时创建新的文本字段 [英] This is the my code,i want to create new text field when user click add link button
本文介绍了这是我的代码,我想在用户单击添加链接按钮时创建新的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<html>
<head>
<title>
Topic HTML
</title>
<link rel="stylesheet" href="Stylesheets/concepts.css"/>
<script type="text/javascript" src="JavaScripts/jquery-1.4.2.min.js"></script>
<style type="text/css">
div{
padding:1px;
}
aaa{
margin-top:200px;
}
bbb{
margin-top:200px;}
</style>
<script type="text/javascript">
$(document).ready(function(){
var counter = 1;
/*var bbb=document.getElementById('reset').value
*/
$("#addButton").click(function () {
if(counter>5){
alert("Only 5 textboxes allow");
/*$('#submit').show();
$('#reset').show();*/
var aaa=document.getElementById('TexBoxDiv2').value;
// alert(aaa);
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after('id').html('<table><tr><td><label style="float:left;margin-left:-140px;" >Links : </label>' +
'<input type="text" name="links[]' + counter +
'" id="links' + counter + '" value="" size="30" style="float:left;" ></td></tr></table>');
//alert(document.getElementById('links'));
/*$('#submit').show();
$('#reset').show();*/
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
/* $("#getButtonValue").click(function () {
var msg = '';
for(i=1; i<counter; i++){
msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();
}
alert(msg);
});*/
});
</script>
</head>
<body>
<center>
<form action="Get_Topic.php" method="post">
<h5><font face="Arial, Helvetica, sans-serif" color="#FF0000">* fields mandatory</font></h5>
<div id='TextBoxesGroup'>
<div id="TextBoxDiv">
<table>
<tr>
<td>Concept Level<font color="red">*</font></td>
<td>
<select id="level_id" name="level_id">
<option name=""></option>
<?php
$topic=mysql_query("select * from technology_levels group by level_name");
while($topic_row=mysql_fetch_array($topic)){
echo "<option value=".$topic_row['level_id'].">".$topic_row['level_name']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Concept Title<font color="red">*</font></td>
<td><input type="text" id="concept_title" name="concept_title" size="30"></td>
</td>
</tr>
<tr>
<td>Cocnept Description <font color="red">*</font></td>
<td><textarea id="concept_description" name="concept_description" rows="10" cols="30" ></textarea></td>
</td>
</tr>
<tr>
<td>Links <font color="red">*</font></td>
<td><input type="text" name="link[]" id="link1" size="30"></td>
<td><input type='button' value='Add Links' id='addButton'></td>
</tr>
<div id="TexBoxDiv2">
<tr>
<td><input type="button" value="Reset" id="reset" ></td>
<td><input type="button" value="Submit" id="submit" ></td>
</tr>
</table>
</div>
</div>
</div>
</form>
</center>
</body>
</html>
其实mycode正在创建新链接,但它创建了aftersubmit按钮,这是不正确的,我想在显示before Submit按钮之前不正确,我该怎么做.
Actually mycode is creating the new link,but it creates aftersubmit button,it is nnot correct,i want to dusplay the before submit button,how can i do that.
推荐答案
(文档).就绪(功能(){ var 计数器= 1 ; /* var bbb = document.getElementById('reset').value */
(document).ready(function(){ var counter = 1; /*var bbb=document.getElementById('reset').value */
(" ).click(函数(){ 如果(计数器5){ alert(" ); /*
("#addButton").click(function () { if(counter>5){ alert("Only 5 textboxes allow"); /*
('#submit').show();
('#submit').show();
这篇关于这是我的代码,我想在用户单击添加链接按钮时创建新的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文