javascript - how to change the value in the html tag using jquery - Stack Overflow

I want to change the param value of the applet tag based on the value from the dropdown.I am new to jq

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
Add a ment  | 

3 Answers 3

Reset to default 3

just 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");
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744144509a4560357.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信