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 134929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:42:08+00:00 2026-05-11T06:42:08+00:00

Inherited an app with a page that has a link that calls the javascript

  • 0

Inherited an app with a page that has a link that calls the javascript function addValueClick(), when I do this a dialog box pops up, I type in some text, and then the text gets put in the select box. Every time a new option is added to the select it gets about 5 pixels narrower. I can’t figure out why this is happening, but it only happens in IE7

Here is the javascript:

function addValueClick() {     var newValue = prompt('Please enter a new value.','');     if (newValue != null && newValue != '')     {         var lst = document.getElementById('lstValues');         var opt = document.createElement('option');         opt.setAttribute('selected', 'true');         opt.appendChild(document.createTextNode(newValue));         lst.appendChild(opt);         updateBtns();         copyValues();     } }  function copyValues() {     var frm = document.forms[0];     var lst = frm.elements['lstValues'];     var hid = frm.elements['hidValues'];     var xml = '<root>';     for (var i = 0; i < lst.options.length; i++)     {         xml += '<value seq_num=\'' + (i + 1) + '\'>' +           lst.options[i].text + '</value>';     }     xml += '</root>';     hid.value = xml; }  function updateBtns() {     var lst = document.getElementById('lstValues');     var iSelected = lst.selectedIndex;     var lnkEdit = document.getElementById('lnkEditValue');     var lnkDelete = document.getElementById('lnkDeleteValue');     var lnkUp = document.getElementById('lnkValueUp');     var lnkDown = document.getElementById('lnkValueDown');     if (iSelected == -1)     {         lnkEdit.style.visibility = 'hidden';         lnkDelete.style.visibility = 'hidden';         lnkUp.style.visibility = 'hidden';         lnkDown.style.visibility = 'hidden';     }     else     {         lnkEdit.style.visibility = 'visible';         lnkDelete.style.visibility = 'visible';          if (iSelected == 0)             lnkUp.style.visibility = 'hidden';         else             lnkUp.style.visibility = 'visible';          if (iSelected == lst.options.length - 1)             lnkDown.style.visibility = 'hidden';         else             lnkDown.style.visibility = 'visible';     } } 

EDIT: The HTML, it’s actually ASP.NET. All the listValueChanged() method does is call updateButtons() above.

<tr>     <TD class=body vAlign=top noWrap align=right><b>Values:</TD>     <TD class=body vAlign=top noWrap align=left><asp:ListBox id='lstValues' runat='server' onchange='lstValuesChange();' Rows='9' onselectedindexchanged='lstValues_SelectedIndexChanged'></asp:ListBox></TD>     <TD class=body vAlign=top noWrap align=left>         <TABLE id='Table2' cellSpacing='2' cellPadding='2' border='0'>             <TR>                 <TD noWrap>                     <asp:HyperLink id='lnkAddValue' runat='server' NavigateUrl='javascript:addValueClick();'>Add</asp:HyperLink></TD>             </TR>             <TR>                 <TD noWrap>                     <asp:HyperLink id='lnkEditValue' runat='server' NavigateUrl='javascript:editValueClick();'>Edit</asp:HyperLink></TD>             </TR>             <TR>                 <TD noWrap>                     <asp:HyperLink id='lnkDeleteValue' runat='server' NavigateUrl='javascript:deleteValueClick();'>Delete</asp:HyperLink></TD>             </TR>             <TR>                 <TD noWrap>&nbsp;</TD>             </TR>             <TR>                 <TD noWrap>                     <asp:HyperLink id='lnkValueUp' runat='server' NavigateUrl='javascript:valueUpClick();'>Up</asp:HyperLink></TD>             </TR>             <TR>                 <TD noWrap>                     <asp:HyperLink id='lnkValueDown' runat='server' NavigateUrl='javascript:valueDownClick();'>Down</asp:HyperLink></TD>             </TR>         </TABLE>     </TD> </TR> 
  • 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. 2026-05-11T06:42:08+00:00Added an answer on May 11, 2026 at 6:42 am

    The issue was where the Option was being added to the Select I changed it to the following and it works perfectly:

    function addValueClick() {     var newValue = prompt('Please enter a new value.','');     if (newValue != null && newValue != '')     {         var lst = document.getElementById('lstValues');         var opt = document.createElement('option');         opt.text = newValue;         opt.value = newValue;         try {             lst.add(opt, null); // real browsers         }         catch (ex) {             lst.add(opt); // IE         }          updateBtns();         copyValues();     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I inherited an Intraweb app that had a 2MB text file of memory leaks
I recently inherited an e-commerce app (Java/Struts) that I'm porting to Rails. The thing
I've inherited a Java web app that actually uses a Silverlight XAP for one
I've inherited a project that involves a administrator app running on node.js talking to
We have a Rails app that has some pages that are available to all
I'm building a Zend-based Web app that will permit third-party extensions. Essentially, this application's
I am working on a Phonegap App that has dynamically created elements. The app
I'm re-designing an app I inherited that sends digital photos from a laptop to
I recently inherited an iPhone app. The original developer did not understand memory management
I have inherited a Grails app, which uses the Acegi 0.5.3 plugin. The application

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.