Solved

ADD TEXT ,EVERY TIME THE BUTTON HITS

Posted on 2007-12-03
3
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 500 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

696 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