• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Javascript - Arraylist

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help, I am trying to accomplish 2 things:

1. I am having a list of objects, how do I get the values into the javascript. Suppose I have 5 rows, if I check on the 3rd checkbox, how do I send the values to javascript.
2. I also want to check only one check box at a time, how do I accomplish, ie. if I check the left one, the right one needs to be unchecked automatically.


Example:


 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This is the second post of yours today that I've moved to the Struts forum. For more information, please read this.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry sheriff.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per my understanding your jsp will some what look like this :

checkbox property1 property2 property3 property4 checkbox.

Are you provinding distinct id's to each row so that the row can be differentiated from other row.
Or you can also provide different id's to each property of jsp.
If you are succeded in doing this then all you have to do is.. document.getElementById(unique id).value;
if you get the id then you can disable the other checkbox by setting its value to false.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rohit,

No I am not providing distinct id to each row. The jsp does not allow me to assign id's, it is giving me error How can I achieve that functionality. Please let me know.

Here is what I have written:

<td><html:multibox id="acpt" property="arIndexVal" onclick="populateList(this, 'A')" >
<bean:write name="item" property="acceptValues" />
</html:multibox></td>

It is giving errors when I write the id="acpt".

Thanks,
Lk.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use styleId in place of id.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rohit, it is working.

I have 2 more questions:

1. What is the equivalent of checked="checked" in multibox because when the page loads all the check boxes are checked. I want them to be unchecked.

2. Ok I got the value to the javascript. Appended it with a string, now how do I pass it back to the form and add it to the javabean. Is it possible. All I want to know is which checkbox I choose, the left one or the right one.
 
Rohit Sharad Sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Luke you can have a look at struts api , there you would be able to find each tag associated with multibox. Try and have a look.

And for setting the value back to bean use document.forms[0].property.value = your value;
and for submitting use document.form.submit();
Do take care your jsp should hold a property name against the value you are submitting and if not use hidden fields as a value holder.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rohit,

I found a way how to keep the checkboxes unchecked while displaying. We need to define the reset method in the form as below:

In the action file call the function:
concurrentCaseInfoForm.reset(mapping, request);


I have another question: please see below code:
JSP:


The notes field at the bottom is a html:text field, so if I change anything in the text field on the jsp, it should store in the form. But when called in the action I am getting a null value. In the action I am calling it as:




I am getting the output having null objects for the bean.

Please let me know, hope I am clear with my question i.e. How do I store the values in the bean if there is any change on the jsp.

Thanks,
Lk.
 
What's a year in metric? Do you know this metric stuff tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic