Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > toggle .value property ?

Reply
Thread Tools

toggle .value property ?

 
 
Jürgen Heyn
Guest
Posts: n/a
 
      02-13-2004
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>


 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      02-13-2004
"Jürgen Heyn" <> wrote in message
news:c0i7vj$17pudb$...
(...)
>
> 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
> {


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


 
Reply With Quote
 
 
 
 
Jürgen Heyn
Guest
Posts: n/a
 
      02-13-2004
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" <> schrieb im Newsbeitrag
news:402d013c$0$70746$...
> "Jürgen Heyn" <> wrote in message
> news:c0i7vj$17pudb$...
> (...)
> >
> > 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
> > {

>
> 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
>
>



 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-13-2004
On Fri, 13 Feb 2004 17:43:59 +0100, Ivo <> wrote:

> Also note that "TRUE" between quotes is not a boolean, but a string.


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

Mike

--
Michael Winter
d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Toggle =?Utf-8?B?c2lhag==?= ASP .Net 1 05-04-2005 09:37 PM
How to toggle between window splits? =?Utf-8?B?a2Q=?= ASP .Net 0 05-02-2005 11:34 AM
how to toggle the visibility of large chunks of a page Dica ASP .Net 3 03-23-2005 03:30 PM
How to toggle visibilty of button inside repeater control =?Utf-8?B?S2VpdGggSGFycmlz?= ASP .Net 1 11-05-2004 03:54 PM
adblock keyboard toggle - firebird 0.7 ˙ųwķė Firefox 2 02-06-2004 09:00 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57