my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes help required in jquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "help required in jquery" Watch "help required in jquery" New topic
Author

help required in jquery

Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
on click of the icon from the parent window i will popup a textarea using jquery.. I will enter text in the popup on submit i need to set the value in the form property.. I am not able to do it.. Any help would be appreciated. I am using struts tags in jsp.

function showPopup(){
$("#popup").dialog('open');
$("#popup").dialog({
bgiframe: false,
autoOpen:true,
resizable:true,
modal: true,
position: 'center',
height: 150,
width: 300,
buttons: {
'Cancel': function() {
$(this).dialog('close');
},
'Add/Update': function() {
$("button").click(function () {
var text = $('textarea').text();
$("justificationComments").val(text); // this line is not working. text is printed properly.
alert(text);// need to set this text value in justificationcomments property
});

$(this).dialog('close');

}

}
});
}

<form>
<img src="<%= request.getContextPath() %>/images/commentsicon.jpg" onclick="showPopup()">
<div id="popup" class="ui-widget-content ui-corner-all" title="Add Justification Comments" style="display:none" >
<html:textarea name="accounts" property="justificationComments" style="width:250px" indexed="true"/>
</div>
</form>
Lilian Chase
Greenhorn

Joined: Jun 14, 2010
Posts: 24
The property tag in struts is equivalent to the name tag.

Perhaps you could try adding the name attribute
eg.
$("textarea[name='justificationComments']).val(text);
Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
I have tried your solution.. not working. any suggestions
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Mate, for cases such as this.

I used a tool such as firebug and firefinder.
Makes debugging act like a charm..

Also, use code tags when posting questions. You'll get more responses from the guru's here..


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

Also, it's important to TellTheDetails -- see ItDoesntWorkIsUseless. You may also use the "styleId" attribute to create an HTML "id" attribute on the input element and access it that way.

In this case, it's important to provide us the rendered HTML, not the JSP: ultimately, all the browser sees is HTML, and that's all jQuery can act on.
Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
Sorry guys.. i m a newbie.

I am using struts(ver 1.2) forms. i have a property which is a list.
<code>
<logic:iterate id="accounts" name="counterpartyForm" property="accounts" type = Account" >
</code>

I have an icon on click i open a popup using jquery.
<code>
<img src="icon.jpg" onclick="showPopup()">
</code>

<script>

function showPopup(){
$("#popup").dialog('open');
$("#popup").dialog({
bgiframe: false,
autoOpen:true,
resizable:true,
modal: true,
position: 'center',
height: 150,
width: 300,
buttons: {
'Cancel': function() {
$(this).dialog('close');
},
'Add/Update': function() {
var text = $('textarea').text();
var area = document.getElementsByName('accounts.justificationComments');
area.value = text;
$(this).dialog('close');
}

}
});
}
</script>


<code>
<div id="popup" class="ui-widget-content ui-corner-all" title="Add Justification Comments" style="display:none" >
<html:textarea name="accounts" property="justificationComments" style="width:250px" indexed="true"/>
</div>

The problem is i am not able to set the textarea value in the property.. Please suggest me a solution.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button. Code tags look like this: "[code]" as explained in the link. Thanks!

Since your question is primarily one about JavaScript, I'll leave this question in this forum--but rather than giving us a JSP fragment, post the rendered HTML instead, since ultimately that's all the browser sees, and many people in this forum may be unfamiliar with Struts and its custom tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help required in jquery