?
Solved

ADD TEXT ,EVERY TIME THE BUTTON HITS

Posted on 2007-12-03
3
Medium Priority
?
166 Views
Last Modified: 2010-04-01
hi,
I want to create button on jsp form, every time the user clicks the button an input of type text is added to the form, HOW I CAN DO THIS
IS IT A FUNCTION, because the onclick didn't call this function
<head>
<script>
var arrInput = new Array(0);
  var arrInputValue = new Array(0);
 
function addInput() {
  arrInput.push(arrInput.length);
  arrInputValue.push("");
  display();
}
 
function display() {
  document.getElementById('parah').innerHTML="";
  for (intI=0;intI<arrInput.length;intI++) {
    document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
  }
}
 
function saveValue(intId,strValue) {
  arrInputValue[intId]=strValue;
}  
 
function createInput(id,value) {
  return "<input type='text' id='test "+ id +"' onChange='javascript:saveValue("+ id +",this.value)' value='"+ 
 
value +"'><br>";
}
 
function deleteInput() {
  if (arrInput.length > 0) { 
     arrInput.pop(); 
     arrInputValue.pop();
  }
  display(); 
}
</script>
</head>
<body>
<form>
<input type="button" value="add item" onclick="addInput();" />
</form>
</body>

Open in new window

0
Comment
Question by:master_programmer
3 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 2000 total points
ID: 20394736
You are missing this object inside your body

document.getElementById('parah')

where is parah?

Create this object:-> <div id="parah"></div>
0
 

Author Comment

by:master_programmer
ID: 20394782
hi,
it did not work , it generate error from statment( document.getElementById('parah'))
where exactly should I add this statment?
and where I have to put <div id="parah"></div>
show me this on my code?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20394792
Change

>>document.getElementById('parah').innerHTML="";

to

var elem = document.getElementById('parah');
alert(elem);
elem.innerHTML = "";

and tell us what you see
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month16 days, 6 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question