Connecting Tech Pros Worldwide Help | Site Map

toggle .value property ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 02:30 PM
Jürgen Heyn
Guest
 
Posts: n/a
Default toggle .value property ?

Good morning,

on form 2 input elements and 1 image are placed. The 1st (Index[0]) one is
"hidden", the 2nd [Index[1]) is an empty textbox.
When clicking the picture I would like to toogle a boolean value. (displayed
in the textbox).
The following function reacts correctly on the first click. Any further
click as no effect (is returns "TRUE" in the textbox).
Where is the mistake ? How can I solve the problem ?
Thank you very much in advance.
Best regards
Juergen Heyn, Wilhelmshaven, Germany

<script language="JavaScript">
<!--

function toggle()
{
if(document.forms[0].elements[0].value="yes")
{
document.forms[0].elements[1].value="TRUE";
document.forms[0].elements[0].value="no";
}
else
{
document.forms[0].elements[1].value="FALSE";
document.forms[0].elements[0].value="yes";
}
}

// -->
</script>

<body>

<form action="">
<p>
<input type="hidden" name="YesNo" value="yes">
<input type="text" name="Textbox" size="20">
<a href="#" onClick=toggle()>
<img src="Button.gif" border="0" width="36" height="36">
</p>
</form>

</body>



  #2  
Old July 20th, 2005, 02:30 PM
Ivo
Guest
 
Posts: n/a
Default Re: toggle .value property ?

"Jürgen Heyn" <j.heyn@gmx.de> wrote in message
news:c0i7vj$17pudb$1@ID-94872.news.uni-berlin.de...
(...)[color=blue]
>
> function toggle()
> {
> if(document.forms[0].elements[0].value="yes")
> {
> document.forms[0].elements[1].value="TRUE";
> document.forms[0].elements[0].value="no";
> }
> else
> {[/color]

I suppose you mean
if(document.forms[0].elements[0].value=="yes")
with double "="
Also note that "TRUE" between quotes is not a boolean, but a string.
HTH
Ivo


  #3  
Old July 20th, 2005, 02:30 PM
Jürgen Heyn
Guest
 
Posts: n/a
Default Re: toggle .value property ?

Hi Ivo,

Thank you very much for the hint. This was actually my mistake.
Coming from Visual Basic the double "==" was unknown.
Thanks again !
Regards
Jürgen


"Ivo" <no@thank.you> schrieb im Newsbeitrag
news:402d013c$0$70746$4a441750@news.euronet.nl...[color=blue]
> "Jürgen Heyn" <j.heyn@gmx.de> wrote in message
> news:c0i7vj$17pudb$1@ID-94872.news.uni-berlin.de...
> (...)[color=green]
> >
> > function toggle()
> > {
> > if(document.forms[0].elements[0].value="yes")
> > {
> > document.forms[0].elements[1].value="TRUE";
> > document.forms[0].elements[0].value="no";
> > }
> > else
> > {[/color]
>
> I suppose you mean
> if(document.forms[0].elements[0].value=="yes")
> with double "="
> Also note that "TRUE" between quotes is not a boolean, but a string.
> HTH
> Ivo
>
>[/color]


  #4  
Old July 20th, 2005, 02:30 PM
Michael Winter
Guest
 
Posts: n/a
Default Re: toggle .value property ?

On Fri, 13 Feb 2004 17:43:59 +0100, Ivo <no@thank.you> wrote:
[color=blue]
> Also note that "TRUE" between quotes is not a boolean, but a string.[/color]

Considering that the value property of form controls is of type string, do
you really think it matters much?

Mike

--
Michael Winter
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.