473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Span onclick with checkbox problem

GTi
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; }
}
}

Dec 14 '05
16 7305
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 -


That would be unfortunate (but typically M$), but I doubt that.
Do you get an error message or something if you omit the `/'?
If yes, what is it and with which code exactly does it occur?
I see that happen quite often in .NET based pages.
So?
.NET also has the runat="" attribute, which is not valid 4.01 strict,
either.


Do not mix up server-side and client-side code. AFAIK `runat' is used
server-side for Web Controls, it does not occur in client-side code.
(CMIIW, I never had a requirement for .NET)

Maybe someone in a .NET group knows something about that.
PointedEars
Dec 14 '05 #11
Thomas 'PointedEars' Lahn wrote:
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 -


That would be unfortunate (but typically M$), but I doubt that.
Do you get an error message or something if you omit the `/'?
If yes, what is it and with which code exactly does it occur?


My understanding is that the input is built with a "controller " - some
sort of built-in class in the .NET framework. In order to omit the '/',
you would have to override the controller.
I see that happen quite often in .NET based pages.


So?


Given that I handle the front-end (HTML layout, CSS, Javascript) for a
..NET web application, it's a PITA.
.NET also has the runat="" attribute, which is not valid 4.01 strict,
either.


Do not mix up server-side and client-side code. AFAIK `runat' is used
server-side for Web Controls, it does not occur in client-side code.
(CMIIW, I never had a requirement for .NET)


It shows up in the HTML tag for form elements.
Maybe someone in a .NET group knows something about that.


Perhaps - it's not my thing, though. All I know is that .NET gives me
crappy code to have to work with. Ah well - back to JS...

Dec 14 '05 #12
On 2005-12-14, GTi <tu****@gmail.c om> wrote:
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.


if you know what boxes there are in the form you can determine which ones
are not checked by their absense from the response.

if you are adding cheeckboxes dynamically and need to know of their
exiostance record it using a hidden field or fields.

Bye.
Jasen
Dec 15 '05 #13
On 2005-12-14, Thomas 'PointedEars' Lahn <Po*********@we b.de> 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.


It seems to support the W3C validator page OK.

Bye.
Jasen
Dec 15 '05 #14
On 2005-12-14, GTi <tu****@gmail.c om> 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.


that's a server side issue, are you using javascript on the server?
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.


you need to let the server know which checkboxes are on the form.
a hidden field that is populated the page is generated if probably the
easiest way to do this.

be aware that people may abuse your server by submitting forma of their own
creation, so check all critical fields to ensure that the submitter has the
right to modify that field.

we had a php script (we think) exploited today someone sent spam to a few
thousand people I left my boss going over the logs.

Bye.
Jasen
Dec 15 '05 #15
GTi
Jasen Betts wrote:
On 2005-12-14, GTi <tu****@gmail.c om> 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.


that's a server side issue, are you using javascript on the server?
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.


you need to let the server know which checkboxes are on the form.
a hidden field that is populated the page is generated if probably the
easiest way to do this.

be aware that people may abuse your server by submitting forma of their own
creation, so check all critical fields to ensure that the submitter has the
right to modify that field.

we had a php script (we think) exploited today someone sent spam to a few
thousand people I left my boss going over the logs.

Bye.
Jasen


For this we WANT the end user to create it's own forms to submit to our
"form" collector. And it is a intranet site - so we don't have mutch
problem with abuse I think.

Dec 16 '05 #16
Jasen Betts wrote:
Thomas 'PointedEars' Lahn wrote:

<snip>
[2] IE does not support XHTML.


It seems to support the W3C validator page OK.


Then the W3C validator page, as served to IE, is not an XHTML document.
Remember that it is the HTTP content-type header that declares the type
of document when it is served over HTTP. That header is definitive, if
the mark-up does not correspond IE will attempt to error-correct it into
the appropriate type (or, more likely, a tag-soup approximation). IE
does not support XHTML.

Richard.
Dec 17 '05 #17

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

Similar topics

6
14102
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>
6
2836
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...
2
11696
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
7
5550
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.
5
3255
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); "/>
1
3982
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
3
3041
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)
7
2346
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?
2
2530
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>
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10323
jinu1996
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...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
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...
0
9138
agi2029
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...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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
3
2983
bsmnconsultancy
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...

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.