Reputation: 195
I've been trying to figure this out but I haven't been able to find an answer that relates to my issue.
I was wondering if it is possible to dynamically enter a value of an object parameter from an input box?
Example:
<form name="myform">
<input type="visibile" name="formvar" value="">
</form>
<object id="myobject">
<param name="color" value="{input destination}" />
I'm basically wondering if its possible to dynamically add values into the "input destination"
Thanks
Upvotes: 3
Views: 352
Reputation: 4256
You could use this object:
or on github
https://github.com/blauharley/TemplateJS
It is able to insert a value of an JSON-Object into a string like this:
var str = '<object id="myobject"> <param name="color" value="{input}{destination}" />...';
var obj = [{ input: { destination: 'a value'} }]
var templ = new TemplateJS();
templ.insertTemplate(obj,str,'#html-id-to-insert-output');
The third parameter ('#html-id-to-insert-output') is used for inserting the output of the insertTemplate-methode.
Hope this helps.
Upvotes: 0
Reputation: 2759
Once the object
is created (when page get loaded), the param
s are passed to that object. So you aren't be able to change the "input destination" after that.
You could delay the creation of object
till the input
is changed like followings.
<form name="myform">
<input type="visibile" name="formvar" value="" onchange="createObject(value)">
</form>
<script>
function createObject(value) {
document.getElementById('document_container').innerHTML =
'<object id="myobject">' +
'<param name="color" value="' + value + '"/>' +
'</object>';
}
</script>
<div id="object_container"></div>
The only drawback is that object
will created over and over again once the input
is changed.
Another option is to ensure the object
plugin offers some APIs which accept setting new parameters, for example myobject.setParam('color', value)
.
Upvotes: 1