/    Sign up×
Community /Pin to ProfileBookmark

Getting problem in java script in mozilla

hi

i have a form where i m dynamically adding a text box means when i click on this button (Add)….

<input type=”button” onclick=”return funcManage(this)” value=”Add”>

funcManage() is called……..

function funcManage()
{
document.getElementById(“manageId”).innerHTML=document.getElementById(“manageId”).innerHTML + ” <input type=’text’ id=’nameid’ name=’managename’ size=’25’ height=’30’>”;
}

this function dynamically adding text box at the position (div)……

<div id=”manageId”>

Now the problem is when i add a text box and fill some text in that box after that when i click on Add button it add new text box but remove the text from old text box.this problem is comming in Mozll Firefox browser.

in IE its working fine.
plz give me some idea…

Thanks
[email][email protected][/email]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsApr 21.2006 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
cnt=0;
function funcManage(){
var ip=document.createElement('INPUT');
ip.id='fred'+cnt;
ip.name='fred'+cnt;
document.getElementById("manageId").appendChild(document.createElement('INPUT'));
cnt++
}

//-->
</script>

this function dynamically adding text box at the position (div)......
<input type="button" name="" value="Add" onclick="funcManage();" >
<div id="manageId"> </div>

</body>

</html>[/CODE]
Copy linkTweet thisAlerts:
@pragatiauthorApr 24.2006 — hi

thnks for ur help...

actually i want 3 text box and 1 drop down menu in one row at a time dynamically.....

and dynamically i want to remove one row at a time in one click...

its creating problem in Mozilla firefox browser..

can u plz help me in that issue?
Copy linkTweet thisAlerts:
@pragatiauthorApr 24.2006 — Hi

Thanks for ur help...

actually i want to add 4 text box and i drop down list in a single row when i click on Add button dynamically.....and everytime when i click on Add button old values should b there in text boxes in Mozilla Forefox...................and also want a remove button when i click on remove button one row(4 textbox and 1 drop down list) should b deleted .

i m new in JavaScript....

can u plz help me?

Pragati
Copy linkTweet thisAlerts:
@vwphillipsApr 24.2006 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>
<script language="JavaScript" type="text/javascript">
<!--


function zxcNewRow(zxct,zxcc){
var zxctarget=zxct;
if (typeof(zxctarget)=='string'){ zxctarget=document.getElementById(zxctarget); }
if (!zxctarget.cary){zxctarget.cary=[]; }
var zxcclone=document.getElementById(zxcc).getElementsByTagName('DIV')[0].cloneNode(true);
zxctarget.appendChild(zxcclone);
zxctarget.cary.push(zxcclone);
zxcNewRowNames(zxctarget,true)
}

function zxcNewRowNames(zxcobj,zxcnew){
for (var zxc0=0;zxc0<zxcobj.cary.length;zxc0++){
if (zxcobj.cary[zxc0].name){
zxcobj.cary[zxc0].name=zxcobj.cary[zxc0].name.replace(/d/g,'');
zxcobj.cary[zxc0].name=zxcobj.cary[zxc0].name+zxc0;
}
if (zxcobj.cary[zxc0].id){
zxcobj.cary[zxc0].id=zxcobj.cary[zxc0].id.replace(/d/g,'');
zxcobj.cary[zxc0].id=zxcobj.cary[zxc0].id+zxc0;
}
}
if (zxcnew){
zxclst=zxcobj.cary[zxcobj.cary.length-1];
zxcips=zxclst.getElementsByTagName('INPUT');
for (var zxc1=0;zxc1<zxcips.length;zxc1++){
if(zxcips[zxc1].type=='text'){
zxcips[zxc1].value='';
}
}
zxcsels=zxclst.getElementsByTagName('SELECT');
for (var zxc2=0;zxc2<zxcsels.length;zxc2++){
zxcsels[zxc2].selectedIndex=0;
}
}
}

function zxcRemove(obj){
var zxcrobj=obj.parentNode;
var zxcp=zxcrobj.parentNode
for (var zxc0=0;zxc0<zxcp.cary.length;zxc0++){
if(zxcp.cary[zxc0]==zxcrobj){
zxcp.cary.splice(zxc0,1);
break;
}
}
zxcp.removeChild(zxcrobj);
zxcNewRowNames(zxcp);
}


function SelCng(obj){
alert(obj.value);
}

//-->
</script>
<body>
<div id="Target1" >
</div>

<input type="button" name="" value="Add Fields" onclick="zxcNewRow('Target1','Clone1');" >
<div id="Clone1" style="position:absolute;visibility:hidden;" >
<div>
<input name="fred0" size="10" >
<input name="tom0" size="10" >
<input name="joe0" size="10" >
<select onchange="SelCng(this);" >
<option value="1" >Option 1</option>
<option value="2" >Option 2</option>
<option value="3" >Option 3</option>
<option value="4" >Option 4</option>
</select>
<input type="button" name="" value="Delete" onclick="zxcRemove(this);" >
<br>
</div>

</div>
</body>

</html>[/CODE]
×

Success!

Help @pragati spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...