Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how to set the value of a boolean in javascript

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I tried setting the value to true (without the "") and it didn't work either
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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>
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic