...

View Full Version : document.getElementById for JS var string



mikemai
09-22-2005, 03:17 AM
I need to set a JS string variable that can ignore carriage returns. I have a working example using a hidden form element:

<form name='nodeinfo>

<input type='hidden' name='myMetadata' value="$node.meta('myValues')">

</form>

<script>
var myString = document.nodeinfo.myMetadata.value;
</script>

Problem is this is limited to 512 characters.

This string is coming from an outside system and could be 1500 characters long. I was wondering how to place it in a hidden table and get the string from there.

Any help appreciated, particularly sample code.

-mike

mikemai
09-22-2005, 03:21 AM
All I get from the following is [object]. How do I get the string Div #1?

<SCRIPT>
function fnGetId(){
// Returns the first DIV element in the collection.
var oVDiv=document.getElementById("oDiv1");
alert(oVDiv);
}
</SCRIPT>
<DIV ID="oDiv1">Div #1</DIV>
<DIV ID="oDiv2">Div #2</DIV>
<DIV ID="oDiv3">Div #3</DIV>
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">

-Mike

mikemai
09-22-2005, 03:34 AM
The following seems to do what I want:

<div style="visibility: hidden;"><table><tr><td id="oDiv1"><p>This is a text</p><p><strong><font size="-1">But here is another test</font></strong></p></td></tr></table></div>
<SCRIPT>

// Returns the first DIV element in the collection.
var oVDiv=document.getElementById("oDiv1").innerHTML;
alert(oVDiv);

</SCRIPT>

Resulting alert gives me:

<p>This is a text</p><p><strong><font size="-1">But here is another test</font></strong></p>

Is there a better way to accomplish this?

-Mike

CrAzY_J
09-22-2005, 05:13 AM
I don't think so, your last post did it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum