hi friends ,
i am on make a dynamic input field creation code ,
my problem is the entered text(value from "add proposition") is washing away , if i press new "add proposition"
my java script is
PHP Code:<script language="javascript" type="text/javascript">
function add()
{
k=document.getElementById("num").innerHTML
k=parseInt(k);
if(!k)
{document.getElementById("num").innerHTML=1;
k=1;}
else{
document.getElementById("num").innerHTML=k+1;
k++;
}
document.getElementById("cat").innerHTML+="<br />type propositon "+(k)+":<input type=\"text\" name=\"prop"+k+"\">is it answer? <input type=\"checkbox\" name=\"ans"+k+"\"> ignore this one:<input type=\"checkbox\" name=\"ign"+k+"\">"
}
</script>
my html code is
PHP Code:<form action="new.php" method="post">
<fieldset>
<legend>Add Question & answer:</legend>
question type:<br />
True or False:<input type="radio" name="radio" value="t">
Objective:<input type="radio" name="radio" value="o">
Other:<input type="radio" name="radio" value="o">
Quesion:<br />
<textarea name="desc" rows="6" cols="35" ></textarea> <br />
<a href="javascript:add()" ><b>add proposition</b></a>
<div id="cat"></div>
<div id="num" style="display:none;"></div>
<br>
<input type="submit" name="submit">
</fieldset>
</form>
how i solve this problem ?


Reply With Quote
Bookmarks