I want to change the param value of the applet tag based on the value from the dropdown. I am new to jquery .can someone tell me how can i do it using jquery .
My applet code :
<applet id="decisiontree" code=".vaannila.utility.dynamicTreeApplet.class" archive="./appletjars/dynamictree.jar, ./appletjars/prefuse.jar" width ="1000" height="500" >
<param name="dieasenmae" value="Malaria"/>
</applet>
My dropdownc code :
<html:select name="AuthoringForm" property="disease_name" size="1" onchange="javascript:showSelected(this.value)">
<option>Malaria</option>
<option>High Fever</option>
<option>Cholera</option>
</html:select></p>
javascript:
function showSelected(value){
alert("the value given from dropdown is "+value);
$("#decisiontree param[name='dieasenmae']").val(value);
}
I want to change the param value of the applet tag based on the value from the dropdown. I am new to jquery .can someone tell me how can i do it using jquery .
My applet code :
<applet id="decisiontree" code=".vaannila.utility.dynamicTreeApplet.class" archive="./appletjars/dynamictree.jar, ./appletjars/prefuse.jar" width ="1000" height="500" >
<param name="dieasenmae" value="Malaria"/>
</applet>
My dropdownc code :
<html:select name="AuthoringForm" property="disease_name" size="1" onchange="javascript:showSelected(this.value)">
<option>Malaria</option>
<option>High Fever</option>
<option>Cholera</option>
</html:select></p>
javascript:
function showSelected(value){
alert("the value given from dropdown is "+value);
$("#decisiontree param[name='dieasenmae']").val(value);
}
Share
Improve this question
edited Aug 29, 2011 at 11:34
bhalkian
asked Aug 29, 2011 at 11:24
bhalkianbhalkian
4995 gold badges15 silver badges32 bronze badges
1
- 1 I'm not sure that the Java plug-in will accept these changes. That would mean to monitor the DOM tree and abort current applet's execution when changes are detected and it doesn't seem sensible. – Álvaro González Commented Aug 29, 2011 at 11:29
3 Answers
Reset to default 3just use:
var myNewValue = 'my new value';
$("#decisiontree param[name='dieasenmae']").val( myNewValue );
Live example on JSBin.
Selector explanation:
$("#decisiontree param[name='dieasenmae']")
^ ^ ^ ^
1 2 3 4
- 1 -> inside the ID
decisiontree
- 2 -> find all elements of the type
param
- 3 -> that has the attribute
name
- 4 -> and that attribute value needs to be
dieasenmae
Now that you know how to change the values, that does not mean it will work! as you need to understand and see how the <applet>
will work, as normally, it loads all values on start, and no matter what you do after in the DOM, the Applet can just ignore it... there should have a refresh applet
somewhere, for that, the easiest way is to follow up to this question:
Is there a way to reload/refresh a java applet from within the applet itself?
$('param').attr('value','your-value');
or
$('param').val('your-value');
Make sure to launch it when dom is ready or use document.ready
$(document).ready(function()
{
$("#decisiontree param").val("newValue");
// or
$("#decisiontree param").attr("value","newValue");
});