• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to set the value of a boolean in javascript

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

I want to set the value of a boolean-type object but I don't know how. I tried to set it with js but it didn't work. By the time I get to the action it gets the value of false.The object "deleted" is contained in a list that belongs to the form.

function deleteRelationships(theForm, object)
{
if (confirm('Do you want to delete the selected relationship(s)?'))
{
object.value="true";
......

}
}

<td width="20%" align="right">

<nested:image property="deleted" src="../images/delete_img.gif" onclickk="alert(this);return false;"
alt="Delete Checked Relationship(s)" title="Delete Checked Relationship(s)" accesskey="D"/>
</td>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
= "true" is a string
= true is a boolean


Eric
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried setting the value to true (without the "") and it didn't work either
 
Sheriff
Posts: 67746
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
"it didn't work"

This is one of the most useless phrases that appears in these forums. How did it not work? What did you expect to happen that didn't? What is object in the function?
[ February 20, 2007: Message edited by: Bear Bibeault ]
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it didn't work because the value of the object (the "deleted" image button) didn't change to true...

I need to set this value to true but not sure if I'm doing it the right way...when I submit the form I check in a struts action the value of the object and it is not set to true...

as I said before The object "deleted" is contained in a list that belongs to the form, but the object itself isn't...
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you passing the object? You do not show us how you are calling the function.

Eric
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as I said before The object "deleted" is contained in a list(narrowerList) that belongs to the form, but the object itself does not...

function deleteRelationships(theForm, object)
{

if (confirm('Do you want to delete the selected relationship(s)?'))
{
object.value=true;

theForm.action.value = 'deleteRelationships';


}
else
{
// Do not submit form
event.returnValue=false;
}

}

===========================
<nested:iterate property="narrowerList">
<tr>
<td width="65%">
<nested:link action="/sam/editEntity"
paramId="id" paramProperty="entity2.entityId" target="main">
<font class="default"><nested:write property="entity2.preferredTerm.name"/></font>
</nested:link>
</td>
<td width="20%" align="right">

<input type="image" name="deleted" src="../images/delete_img.gif" onClickk="deleteRelationships(this.form,this)"
alt="Delete Checked Relationship(s)" title="Delete Checked Relationship(s)" accesskey="D"/>
</td>
</tr>
</nested:iterate>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic