Topic: how to access innerhtml element (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28786" title="Pages that link to Topic: how to access innerhtml element (Page 1 of 1)" rel="nofollow" >Topic: how to access innerhtml element <span class="small">(Page 1 of 1)</span>\

 
luz kazar
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Jan 2007

posted posted 01-03-2007 04:01

Hi guys...i'm kinda new in this js language...i was wondering can anybody help me with this code....well problem maybe sound a bit silly..well I was wondering how to get the all the value from the txtbox so that,I can validate all the data that have been key in by the user....thanking u all in advance for your time in reviewing my msg...may god bless u all.

code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
var numLinesAdded = 0;
function generateRow() {
var d=document.getElementById("div");
var addbut=document.getElementById("addsub");

d.innerHTML+="<table width='90%' bgcolor='#E9E9E9' border='0' cellpadding='0' cellspacing='0'><tr class='ContentTableText'><td>Name</td><td><input name='ConNameMs[]' type='text' id='ConNameMs[]' class='ContentTableText' size='38' /></td></tr><tr class='ContentTableText'><td>Address</td><td><input name='ConAdd[]' type='text' id='ConAdd[]' class='ContentTableText' size='38' /></td></tr><tr class='ContentTableText'><td>Age</td><td><input name='ConAge[]' type='text' id='ConAge[]' class='ContentTableText' size='38' /></td></tr></table><br>";
//d.innerHTML+="<input type='text' maxlength='5' name='txt1_" + numLinesAdded + "' onkeypress='focusNext(this)'>";
numLinesAdded++;
if(numLinesAdded=="5"){
addbut.disabled = true;
}
}
function test(){
alert("hi");
var thediv=document.getElementById("div");
var theelementcon=thediv.getElementsByTagName("input");
for(i=0;i<theelementcon.length;i++){
theelementcon[i].innerHTML=document.getElementById("ConNameMs[]").value;
}
}
</script>
</head>

<body>
<div id="div" align="center"></div>
<input type="button" value="Add Contact" id="addsub" onclick="generateRow()" class="ContentTableText"/>
<input type="button" value="Test" id="test" onclick="test()" class="ContentTableText"/>
</body>
</html>

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-04-2007 08:58

I'm not sure what you're up to here - I can't find a closing </table>, I have no clue why you're creating the table via javascript in the first place,
theelementcon[i].innerHTML=document.getElementById("ConNameMs[]").value; overwrites the innerHTML each time, which might be your problem,
but then, document.getElementById("ConNameMs[]").value will continously return the same value.
That [] is only parsed server side, as far as I remember, so you'd at the very least have to do a

code:
var els = document.getElementsByName("conNameMs[]");
for ( e in els )
{
  theelementcon[i].innerHTML += els[e].value + "\r\n";
}




I hope my rambelings can help you - if not, holler up and explain what you were trying to do in the first place.

So long,

->Tyberius Prime



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu