Advertisement

10.30.2007 at 08:29AM PDT, ID: 22927171
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Change the function to include the textbox inside the row tag instead of the row

Asked by Gemini532 in Active Server Pages (ASP), JavaScript, SQL Query Syntax

Tags: ,

Hello Everyone, I have a function here which ADDS a new row whenever the add button at the end of the row is pressed, can you help me change this function to one that would add a new textbox in the new row as well and change its name
Initially the name of the first textbox is SHName1
so when a new one is added I want it to be SHName2
and the next SHName3
and the next SHName4, etc...
Can you help me rewrite this function to do that rather than add a new row, I need it to add a new textbox inside the row...
In other words when Add is pressed I want to get a new textbox, instead of a new row... Also the add button should not be added more than once... the add button should be only one but when it is pressed it should add another textbox... Can this be done?

Here is my current code, but it's incorrect....

This is my code so far:

      <form action="115-SHUpdate.asp" id="OPICForm" name="OPICForm" method="post" onSubmit = "return validateSubmit();" >
      </div>


<%
'Get the saved values, if any
dim iApplicationID, sqlValues, rsValues
iApplicationID = Session("ApplicationID")

' Declare all of the values for Form 115
dim sSHName, sSHCountry, sSHPercentage
dim counter
counter = 0  '<--------THIS VARIABLE SHOULD KEEP TRACK OF HOW MANY ROWS HAVE BEEN ADDED BY THE USER

sqlValues = "SELECT * FROM Shareholders WHERE FK_ApplicationID=" & iApplicationID

set rsValues = Server.CreateObject("ADODB.Recordset")

with rsValues
      .open sqlValues, objConn,3,3
      if .Recordcount=1 then

            ' Save the values
            sSHName                     = .Fields("SHName")
            sSHCountry                      = .Fields("SHCountry")
            sSHPercentage               = .Fields("SHPercentage")

      else
            objConn.execute("INSERT INTO Shareholders (FK_ApplicationID) VALUES (" & iApplicationID & ")")
      end if
end with
'.close
%>

<script language="javascript">

var bComplete = true;

function ValidateSubmit(){
      bComplete = true;
      alert(document.OPICForm.SHName);
      //ValidateTextBox(document.OPICForm.SHName);
}

//START CODE THAT ADDS NEW ROWS WHEN THE ADD BUTTON IS PRESSED
      function cloneRow(tblId)
      {
            var tbl = document.getElementById(tblId);
            var tbody = tbl.getElementsByTagName('tbody')[0];
            var rowColl = tbody.getElementsByTagName('tr');
            var index = rowColl.length -1;
            var row = rowColl[index];
            var newRow = row.cloneNode(true);
            setRow(newRow, index);
            tbody.appendChild(newRow);
      }
     
      function setRow(row, index)
      {
            var inputs = row.getElementsByTagName('input');
                  alert(inputs.value);
            for(var i in inputs)
            {
                  inputs[i].id = "whatever" + index + i;
                  inputs[i].name = "whatever" + index + i;
                  if(inputs[i].type == 'text')
                  {
                        inputs[i].value = "";
                  }
            }
      }
//END CODE THAT ADDS NEW ROWS WHEN THE ADD BUTTON IS PRESSED
</script>
</head>
<body>


<table id="mytable" class="content" width = "550" border = "1" cellpadding="1" cellspacing="1">
      <thead>
      <TR class = "heading">
            <TD>
            <strong>Shareholder Name</strong>
            </TD>      
            <TD>
            <strong>Country of Citizenship or Incorporation</strong>
            </TD>      
            <TD>
            <strong>Percent Owned</strong>
            </TD>
            <TD>
            <strong>Add New Shareholder</strong>
            </TD>      
      </TR>
     </thead>
     <tbody>
      <TR>
            <TD>
            <input type = "text" name = "SHName" id = "SHName">
            </TD>      
            <TD>
            <input type = "text" name = "SHCountry" id = "SHCountry">
            </TD>      
            <TD>
            <input type = "text" name = "SHPercentage" id = "SHPercentage"  size = "3" maxlength="3">
            </TD>
            <TD>
            <input type = "button" name = "Add" value = "Add" onClick="cloneRow('mytable');"/>
            </TD>      
      </TR>
     </tbody>
     <tfoot>
      <TR>
            <TD colspan="3">&nbsp;</TD>
      </TR>
     </tfoot>
    </table>
     
<br><BR>
<center>
  <input type="submit" id="submitShareholders"  value="Submit Data" />
</center>  Start Free Trial
 
Loading Advertisement...
 
[+][-]10.30.2007 at 08:51AM PDT, ID: 20178320

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 09:37AM PDT, ID: 20178786

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 09:38AM PDT, ID: 20178805

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.30.2007 at 10:55AM PDT, ID: 20179466

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), JavaScript, SQL Query Syntax
Tags: javascript, td
Sign Up Now!
Solution Provided By: rlbalan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.06.2007 at 09:00AM PST, ID: 20225436

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 09:38AM PST, ID: 20225801

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 10:27AM PST, ID: 20226224

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628