I want to use a 'smarter' checkbox using span. When a user press the
text the checkbox is checked. But this dos't work as expected. Any
idea?
<span style="cursor:p ointer;" onclick="ClickB oxClick('IsProd ');">
<input type="checkbox" name="IsProd" value="1" />
Is a Product
</span>
function ClickBoxClick(o bj)
{
if(document.get ElementsByTagNa me)
{
var el = document.getEle mentById(obj);
if(el.checked) { el.checked=fals e; }
else { el.checked = true; }
}
} 16 7303
> "GTi" <tu****@gmail.c om> wrote: news:11******** **************@ g44g2000cwa.goo glegroups.com.. .. I want to use a 'smarter' checkbox using span. When a user press the text the checkbox is checked. But this dos't work as expected. Any idea? <span style="cursor:p ointer;" onclick="ClickB oxClick('IsProd ');"> <input type="checkbox" name="IsProd" value="1" /> Is a Product </span> function ClickBoxClick(o bj) { if(document.get ElementsByTagNa me) { var el = document.getEle mentById(obj); if(el.checked) { el.checked=fals e; } else { el.checked = true; } } }
This is what label is for.
<input id="mybox" type="checkbox" name="IsProd" value="1">
<label for="mybox" style="cursor:p ointer;">Is a Product</label>
--
BootNic Wednesday, December 14, 2005 9:22 AM
Our earth is degenerate in these latter days; bribery and corruption are common; children no longer obey their parents; and the end of the world is evidently approaching.
*Assyrian clay tablet 2800 B.C.*
It shuld be:
<label for="mybox" style="cursor:p ointer;">
<input id="mybox" type="checkbox" name="IsProd" value="1">
Is a Product</label>
But then I have another problem:
Using checkboxes in a form dosn't post back the result when it is not
checked. That is a problem. So my next step was to extend this function
with a hidden input fields with values 0 or 1 if the checkbox.
This solution does not solve that problem - or?
GTi wrote: I want to use a 'smarter' checkbox using span. When a user press the text the checkbox is checked. But this dos't work as expected. Any idea?
<span style="cursor:p ointer;" onclick="ClickB oxClick('IsProd ');"> <input type="checkbox" name="IsProd" value="1" />
^^^^[1] ^[2]
[2] IE does not support XHTML.
Is a Product </span>
<input type="checkbox" name="IsProd" id="IsProdID" value="1"><labe l
for="IsProdID"> Is a Product</label>
No scripting is needed here at all, and the best of it is that it is
Valid HTML 4.01 Strict.
function ClickBoxClick(o bj) { if(document.get ElementsByTagNa me)
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ { var el = document.getEle mentById(obj);
^^^^^^^^^^^^^^^ ^^^^^^^^ if(el.checked) { el.checked=fals e; } else { el.checked = true; } } }
Your script does not work because names are not IDs.[1]
You are insufficiently feature-testing the wrong property
and your indentation style allows for improvement, BTW.
PointedEars
OK my bad - the label can be almost anywhere on the page as long as it
ref to the id name.
But it will not solve my other problem I think.
GTi wrote: It shuld be: <label for="mybox" style="cursor:p ointer;"> <input id="mybox" type="checkbox" name="IsProd" value="1"> Is a Product</label>
It CAN be, there is no MUST. However, experience shows that including
a label element for an ID that was not parsed yet is error-prone, so it
SHOULD NOT be as above but instead as BootNic and I posted.
But then I have another problem: Using checkboxes in a form dosn't post back the result when it is not checked. That is a problem.
That is no problem. Why would you be interested in unchecked checkboxes?
So my next step was to extend this function with a hidden input fields with values 0 or 1 if the checkbox. This solution does not solve that problem - or?
This "solution" introduces more problems than it "solves", for example
the dependency on client-side script support and thus the inevitable
unreliability of the posted data.
PointedEars
Thomas 'PointedEars' Lahn wrote: But then I have another problem: Using checkboxes in a form dosn't post back the result when it is not checked. That is a problem. That is no problem. Why would you be interested in unchecked checkboxes?
When the target page recieves the form it will not see that the
checkbox was on the form and leaves the value unchanged in the
database. But if I have a value telling it is turned off it will change
the value in the database. I know that this is by design, but I'm
trying to keep a common target page for all kind of changes in the
database (on one table). That way I can have several forms and only
display what fields I want to change with only one target page. So my next step was to extend this function with a hidden input fields with values 0 or 1 if the checkbox. This solution does not solve that problem - or?
This "solution" introduces more problems than it "solves", for example the dependency on client-side script support and thus the inevitable unreliability of the posted data.
PointedEars
GTi wrote: Thomas 'PointedEars' Lahn wrote: > But then I have another problem: > Using checkboxes in a form dosn't post back the result when it is not > checked. That is a problem. That is no problem. Why would you be interested in unchecked checkboxes?
When the target page recieves the form it will not see that the checkbox was on the form and leaves the value unchanged in the database. But if I have a value telling it is turned off it will change the value in the database. I know that this is by design, but I'm trying to keep a common target page for all kind of changes in the database (on one table). That way I can have several forms and only display what fields I want to change with only one target page.
So you just need to assume a default value server-side and
modify the database always or compare with the value in the
DB first, or use groups of two radiobuttons.
PointedEars
Thomas 'PointedEars' Lahn wrote: GTi wrote:
I want to use a 'smarter' checkbox using span. When a user press the text the checkbox is checked. But this dos't work as expected. Any idea?
<span style="cursor:p ointer;" onclick="ClickB oxClick('IsProd ');"> <input type="checkbox" name="IsProd" value="1" /> ^^^^[1] ^[2]
[2] IE does not support XHTML.
But, apparantly, .NET seems to force it - I see that happen quite often
in .NET based pages.
..NET also has the runat="" attribute, which is not valid 4.01 strict,
either.
I'm just wondering if you have any suggestions on how to deal with that
(and don't say don't use .NET - it's not an option, unfortunately :( )
It's been a source of frustration to me for some time, but I have no
ideas how to deal with it.
Tony wrote: Thomas 'PointedEars' Lahn wrote: GTi wrote:
I want to use a 'smarter' checkbox using span. When a user press the text the checkbox is checked. But this dos't work as expected. Any idea?
<span style="cursor:p ointer;" onclick="ClickB oxClick('IsProd ');"> <input type="checkbox" name="IsProd" value="1" /> ^^^^[1] ^[2]
[2] IE does not support XHTML.
But, apparantly, .NET seems to force it - I see that happen quite often in .NET based pages.
.NET also has the runat="" attribute, which is not valid 4.01 strict, either.
I'm just wondering if you have any suggestions on how to deal with that (and don't say don't use .NET - it's not an option, unfortunately :( ) It's been a source of frustration to me for some time, but I have no ideas how to deal with it.
Yes - it is .NET and no I don't have any solution for that.
BUT i'm doing some "the hard way" by creating my own classes and tags.
I always use Firefox and IE to test my code. Firefox has many
extensions for HTML validations. And yes - it complains a lot about
..NET generated code. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fabri |
last post by:
I shoul want to know the content o a certain span:
************************************************************************
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
|
by: hsomob1999 |
last post by:
so i have a <ul> and I allow the user to append items to it. The
problem is that on mozilla the <span class="line"> which is just a line
to divide the sections
gets overlaped and doesnt move down and adjust to the newly added items
like it does in iE. It just occured to me that i dont really have to
use a span, and a html <hr> tag could do the trick -I will go try. But
aside from that could some one explain why this occurs? And will I get...
|
by: Homa |
last post by:
Hi,
I have a Datagrid that uses as a shopping cart and have a checkbox
template column in it. I can't add both OnCheckedChanged Event and
onclick client script for it.
I want to do two things:
1. I want the checkbox fires CheckedChanged event. I did this as
|
by: Ryan Ternier |
last post by:
I have a check box on my page. When a user clicks this box I have a
confirmation box come up.
When the user clicks OK, true is returned, otherwise false.
Now, when true is Returened, I want the form to postback. I can't figure
out how to do this.
Here is the code I use to put the OnClick event on the CHeckbox.
|
by: ste.paoletti |
last post by:
I have a problem with css
I have a this xhtml code:
<span>
<span>
<span/>
<input type="radio"/>
....
<span/>
<input type="button" onclick ="var s=document.createElement('span');
this.previousSibling.firstChild.appendChild(s); "/>
| |
by: Fao, Sean |
last post by:
I'm trying to set the title attribute on a CheckBox and I'm having some
issues in ASP.NET 1.1.
The title attribute in the following example is valid in HTML 4.01
Transitional:
<input id="MyCheckBox" type="checkbox" title="ToolTip">
However, ASP.NET doesn't like it. No matter what I do, ASP.NET places
my control inside of a span tag with the title attribute set in the
|
by: juicy |
last post by:
Hi,
I have 4 check box and a textarea. When user check each check box, it will
append text in the textarea. In onclick event, it calls getSurcharge
function and append value in variable output. My problem is I failed to
get value in php variable inside the function.
Please give some idea on the reason of the problem. Thanks.
<script language="JavaScript">
function getSurcharge(id)
|
by: mavigozler |
last post by:
IE7 does not appear to set an event on contained text inside SPAN elements
whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML
recommendation. Firefox appears to conform.
Is that so?
|
by: swethak |
last post by:
Hi,
i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code
<script>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |