473,378 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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>
Jul 20 '05 #1
3 2356
Ivo
"Jürgen Heyn" <j.****@gmx.de> wrote in message
news:c0*************@ID-94872.news.uni-berlin.de...
(...)

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
Jul 20 '05 #2
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:40***********************@news.euronet.nl...
"Jürgen Heyn" <j.****@gmx.de> wrote in message
news:c0*************@ID-94872.news.uni-berlin.de...
(...)

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

Jul 20 '05 #3
On Fri, 13 Feb 2004 17:43:59 +0100, Ivo <no@thank.you> 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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: leegold2 | last post by:
I wondered if anyone would give me code- I think it would be easy, but I'm a complete newbie. What I want to do is to show many tables in a brief truncated format and then for each table offer the...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
2
by: John | last post by:
Hi How can I create a toggle button on a toolbar that would enable/disable editing on the current form? Thanks Regards
4
by: Neil Coleclough | last post by:
I am constructing a database to process product returns for my Company. I have a number of toggle buttons to identify the stage to which each return has been processed. For example, clicking the...
2
by: Mel | last post by:
Hi, is there any way I can implement toolstrip toggle button simular to the MS Word alignment button? if one toggle button already pressed down, if user click on the "pushed down button", the...
4
by: deko | last post by:
Basic question about checking the value of Toggle/Check/Combo/OptionGroups.... Checking like this: If Me!chkCheckBox Then ... End If and like this:
3
by: Killer42 | last post by:
Hi all. I have a frame with some toggle buttons in it. All is working fine, except that the user can't tell which option is selected to begin with. How do I set one of the toggle buttons to the...
1
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I...
2
by: Chuck | last post by:
How can I make an array of command buttons (or toggle buttons) on a form and have a text box on the same form display the index of the button clicked? This works very well in VB6, but I can't...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.