PDA

View Full Version : innerHTML ?


visual
05-27-2004, 10:47 AM
Hi !

Trouble with :

<object id="TEXT" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="txt/info-EN.txt">
<param name="UseHeader" value="true">
<param name="FieldDelim" value="|">
</object>

I wanna change the value from name="DataURL".
value="txt/info-EN.txt" to value="txt/info-DE.txt
___________________________________________________________

I use this Script:

<script language="JavaScript">
function changeAction(formId, toWhat){
document.getElementById(formId).value = toWhat;
}
</script>
___________________________________________________________
HTML:


<input type="Button" value="DE" onclick="changeAction('theForm', 'txt/info-DE.txt');">

<object id="TEXT" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">

<param id="theForm" name="DataURL" value="txt/info-EN.txt">
<param name="UseHeader" value="true">
<param name="FieldDelim" value="|">
</object>

___________________________________________________________

It doesn't run ! Can you help ?

agent002
05-27-2004, 11:17 AM
I don't think you can change the params, but you can always give it a try:
<script type="text/javascript">
function changeParam(obj, paramName, newValue){
var nodes = obj.childNodes;
for(var i = 0; i < nodes.length; i++){
if(nodes[i].tagName && nodes[i].tagName.toLowerCase() == 'param' &&
nodes[i].name == paramName){
nodes[i].value = newValue;
return false;
}
}
}
</script>
<input type="Button" value="DE" onclick="changeParam(document.getElementById('TEXT'), 'DataURL', 'txt/info-DE.txt');">

However, I don't think it will work. You may need to rewrite the entire object:
function rewriteObject(obj, newDataURL){
obj.outerHTML = '<'+'object id="TEXT" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"> \n' +
'<'+'param id="theForm" name="DataURL" value="'+newDataURL+'"> \n' +
'<'+'param name="UseHeader" value="true"> \n' +
'<'+'param name="FieldDelim" value="|"> \n' +
'<\/object>';
}
<input type="Button" value="DE" onclick="rewriteObject(document.getElementById('TEXT'), 'txt/info-DE.txt');">

visual
05-27-2004, 11:47 AM
Hi Jere !

Yes, it works !
But finaly i got one more question, i'm sorry !
How can i use this Script from a other Frame ?

visual

agent002
05-27-2004, 11:52 AM
Just out of interest, which one worked?

Well, if you have two frames names FrameA and FrameB, and the object and the function is in FrameA, and you want to call the function from FrameB, make the link:
onclick="parent.FrameA.rewriteObject(parent.FrameA.document.getElementById('TEXT'), 'txt/info-DE.txt');"

visual
05-27-2004, 12:11 PM
Hi Jere !

I tried the last one !

Thank you very much !

visual