Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:49:07+00:00 2026-05-13T21:49:07+00:00

I have a button that, when pressed, will add a new HTML row. Within

  • 0

I have a button that, when pressed, will add a new HTML row. Within these rows are two combo boxes: cboOffsetGroup and cboOffsetType. Depending on what is selected in cboOffsetGroup, the options for cboOffsetType will change. I do this using a refreshPage() function in Javascript. It works fine in the first row, but in the subsequently added rows, I cannot figure out how to call the refreshPage() funciton so that I can populate the appropriate options for cboOffsetType. Any help on this is appreciated. Note that I’m pretty much a novice at this, and realize this may not be the best code, but it’s what I have to work with. Thanks!

 <%
Dim CN, RS, vIndexOffset, vOffsetGroup

Set CN = GetDataConnection

vIndexOffset = Request.Form("txtOffsetIndex")
%>

<body>
<form name="frmExceptionInput" id="frmExceptionInput" method="post">
<input type="hidden" name="txtAction" id="txtAction" value="">

<table width="50%" id="tblOffsetDetail">
<tbody>
    <tr>
        <td colspan="2">
        <input type="button" class="button" value= "Add New Item" id="btnNewOffsetItem" name="btnNewOffsetItem" onClick="javascript:addNewOffsetItem();">
        <input type="hidden" id="txtOffsetIndex" name="txtOffsetIndex" value="1">
    </td>
    </tr>
    <tr>
        <td>
            <p>
            <select name="cboOffsetGroup1" id="cboOffsetGroup1" onChange="refreshPage();">
                <option value="0"></option>
                <%
                Set RS = CN.Execute ("spSelectGroup")
                If Not RS.EOF Then
                    Do While Not RS.EOF
                        %>
                        <option value='<%= RS("offsetGroupID")%>'<%If RS("offsetGroupID") = Request.Form("cboOffsetGroup" & vIndexOffset) Then Response.Write " selected"%>><%= RS("offsetGroup")%></option>    
                        <%
                        'Get next record
                        RS.MoveNext
                    Loop
                End If  
                %>
            </select>
            </p>        
        </td>
        <td>
            <p>
            <select name="cboOffsetType1" id="cboOffsetType1">
            <%
            'If the user changes the combo box selected, set vOffsetGroup = the value selected by the user on the page.
            If Request.Form("txtAction") = "Change Selection" Then
                vOffsetGroup = Request.Form("cboOffsetGroup" & vIndexOffset)
            End If
            %>  
            <option value="0"></option>
            <%
            Set RS = CN.Execute ("spSelectType @vOffsetGroup='" & vOffsetGroup & "'")
            If Not RS.EOF Then
                Do While Not RS.EOF
                    %>
                    <option value='<%= RS("offsetItemTypeID")%>'<%If Request.Form("cboOffsetType1") = RS("offsetItemTypeID") Then Response.Write "selected"%>><%= RS("offsetItemType")%></option>
                    <%
                    'Get next record
                    RS.MoveNext
                Loop
            End If
            %>
            </select>
            </p>
        </td>
    </tr>
</tbody>
</table>

</form>
</body>

<script language="javascript">

function refreshPage()
{
    var refreshPage = document.getElementById("frmExceptionInput");

    //If this function is called, the value of txtAction will become "Change Selection."
    document.getElementById("txtAction").value = "Change Selection";

    refreshPage.submit();
}

//Display additional rows.
function addNewOffsetItem()
{
    var iX = document.getElementById("txtOffsetIndex").value;
    iX ++;
    document.getElementById("txtOffsetIndex").value = iX;

    var tbl = document.getElementById("tblOffsetDetail").getElementsByTagName("TBODY")[0];
    var tr = document.createElement("TR");
    tbl.appendChild(tr);

    //cboOffsetGroup1
    var tdOffsetGroup = document.createElement("TD");
    tr.appendChild(tdOffsetGroup);

    var p = document.createElement("P");
    tdOffsetGroup.appendChild(p);

    var cboOffsetGroup = document.createElement("select"); 
    p.appendChild(cboOffsetGroup);

    cboOffsetGroup.id = "cboOffsetGroup" + iX;
    cboOffsetGroup.setAttribute('name','cboOffsetGroup' + iX);

    var cboOffsetGroup1 = document.getElementById("cboOffsetGroup1");
    var i = 0;

    for (i = 0; i < cboOffsetGroup1.children.length; i++)
        {
            var opt = document.createElement("option");
            opt.value = cboOffsetGroup1 [i].value;
            opt.innerText = cboOffsetGroup1 [i].innerText;
            cboOffsetGroup.appendChild(opt);
        }   

    //cboOffsetType1
    var tdOffsetType = document.createElement("TD");
    tr.appendChild(tdOffsetType);

    var p = document.createElement("P");
    tdOffsetType.appendChild(p);

    var cboOffsetType = document.createElement("select"); 
    p.appendChild(cboOffsetType);

    cboOffsetType.id = "cboOffsetType" + iX;
    cboOffsetType.setAttribute('name','cboOffsetType' + iX);

    var cboOffsetType1 = document.getElementById("cboOffsetType1");
    var i = 0;

    for (i = 0; i < cboOffsetType1.children.length; i++)
        {
            var opt = document.createElement("option");
            opt.value = cboOffsetType1 [i].value;
            opt.innerText = cboOffsetType1 [i].innerText;
            cboOffsetType.appendChild(opt);
        }
}

</script>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:49:08+00:00Added an answer on May 13, 2026 at 9:49 pm

    You’re better of using JQuery for this sort of task.

    http://api.jquery.com/add/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You probably want to call setlocale() first, "LC_ALL" should do… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Linux Ubuntu Desktop Jaunty Firebug FireCookie Pixel Perfect Web developer… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Your code should look like this: var par = [];… May 14, 2026 at 9:06 am

Related Questions

I have a script. In it is code. I have a page. In it
If you own Android phone you are no doubt have noticed how in the
I have an application with 5 UIViewController s each inside a corresponding UINavigationController ,
Situation : C#, .NET 3.5, WinForms Objective : Form1 has a Button that can
I have a standard ASP.NET 2.0 web page with a Delete button on it.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.