From 8c969a936743c448391f2afb061cec08f4b6e79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Betn=C3=A9r?= Date: Sat, 20 May 2006 22:37:41 +0000 Subject: [PATCH] Fix element id:s for dynamically added elements --- admin-root/config.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/admin-root/config.js b/admin-root/config.js index 32999003..9d818f37 100644 --- a/admin-root/config.js +++ b/admin-root/config.js @@ -9,7 +9,6 @@ Event.observe(window,'load',init); else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) navigator.OS = 'nix';*/ //Inform user if server restart needed -//disable all page elements when read only //better errormessage for not writable config //make tabs? //create the path/file browser @@ -243,8 +242,13 @@ var Config = { } var frag = document.createDocumentFragment(); span = span.cloneNode(true); - span.getElementsByTagName('label')[0].setAttribute('for','hej'); - span.getElementsByTagName('input')[0].id = 'hej'; + var id = span.getElementsByTagName('input')[0].id; + var num = parseInt(id.match(/\d+$/)); + num++; + var id = id.replace(/\d+$/,'') + num; + + span.getElementsByTagName('label')[0].setAttribute('for',id); + span.getElementsByTagName('input')[0].id = id; span.getElementsByTagName('input')[0].value = ''; var hrefs = span.getElementsByTagName('a'); if ('Netscape' == navigator.appName) {