2

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="com.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); 
}
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. Commented Aug 29, 2011 at 11:29

3 Answers 3

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?

Sign up to request clarification or add additional context in comments.

8 Comments

i was not able to see those change the changes made this way are in memory or changes done this way will reflect in my jsp
I have explained you that you could see no changes at all, please read.
just to reiterate through whatever change we do using jquery is done in memory and is not persisted in the harddisk .is there any way to persist the changes in the harddisk using jquery .
DOM manipulation is always in memory, every time you refresh the page, it will load the state that was previously wrote. What you can do however, is to use a dynamic language (php, .net, jsp, ror, etc) to construct the HTML prior to the first load, or if you want to be using only javascript you can host the dropdown value in a cookie or make use of local storage (not available in IE), and change that value first and reload the applet. You can never change the source using only a client state. Imagine the security problems if that was possible ;)
you mean is there any way i can generate html from the changed DOM using jsp .if yes can you get me some pointer on that . would appreciate your help.
|
2
$('param').attr('value','your-value');

or

$('param').val('your-value');

Make sure to launch it when dom is ready or use document.ready

6 Comments

that will never work if it has more than one param, you will change all of them!
He has mentioned about one param only. And never work!!! At least 'ALL' includes this one.
you should never thing like that if you want to be a good developer!
I agree that your answer is better, but you can't say my one will never work.
I mentioned that will never work if more than one <param> is in the code, I was clear :)
|
0
    $(document).ready(function()
    {
       $("#decisiontree param").val("newValue");
       // or
      $("#decisiontree param").attr("value","newValue");
});

4 Comments

that will never work if it has more than one param, you will change all of them!
You have } missing at last line
@balexandre You should know edit is not allowed if less than 6 non-space characters are edited. And there is only 1 to edit fairly. If he edits he can add more if wishes
@Useman you can easily make up more chars saying I just updated the code... 1 char never stopped no one ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.