Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 13, 2009, 05:39 AM   #1
stratocratic
macrumors newbie
 
Join Date: Jun 2009
iPhone Safari not honoring 'for' attribute of html label tag...anyone else notice?

This is regarding development of a web app, but this seemed like the most appropriate board for the matter. I'm sure someone will let me know if it isn't...

iPhone Safari isn't honoring the use of the "for" attribute in the <label> tag, as in, it's not selecting the corresponding radio button/checkbox when the content included in the label is touched. I experience this on iPhone OS 3.1, for what it's worth.

simple example:

<form>
<label for="foo">foo</label>
<input type="radio" id="foo" name="asdf" value="foo" />

<label for="bar">bar</label>
<input type="radio" id="bar" name="asdf" value="bar" />
</form>


I'm not able to duplicate the issue in Safari 4.0.3 (6531.9) on OS X 10.6.1.

Has anyone encountered this before?
stratocratic is offline   0 Reply With Quote
Old Sep 14, 2009, 05:05 AM   #2
stratocratic
Thread Starter
macrumors newbie
 
Join Date: Jun 2009
I suppose I might submit this to apple as a bug report.
stratocratic is offline   0 Reply With Quote
Old May 6, 2011, 12:38 PM   #3
Kngus
macrumors newbie
 
Join Date: May 2011
Solution

Hey there,

I have actually been looking around the web to provide this answer, as I couldn't find a resolution when I had this problem myself.

I put the attribute onchange="" on my label, and that made the for="" attribute work.

So, when I was having this problem my code looked like this:

<input type="checkbox" id="chkRemember" name="chkRemember" value="1"/><label for="chkRemember">Remember me</label>

And it didn't work. This did work:

<input type="checkbox" id="chkRemember" name="chkRemember" value="1"/><label onclick="" for="chkRemember">Remember me</label>

I thought i messed something up, so I undid my work then tested, then redid my work and tested again.. sure enough, an empty onchange attribute worked.

Hope this helps,
Angus
Kngus is offline   0 Reply With Quote
Old May 6, 2011, 01:23 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Which attribute is it: onchange or onclick?

Your code shows onclick, but your description says onchange (twice).

You don't need to post a new reply to this. Simply edit your post and save the changes.
chown33 is offline   0 Reply With Quote
Old May 6, 2011, 09:28 PM   #5
ulbador
macrumors 68000
 
ulbador's Avatar
 
Join Date: Feb 2010
The <LABEL> tag doesn't work in Mobile Webkit, probably to stop the interfering with the tap-to-select-text functionality.

http://twitter.com/#!/kapowaz/status/21674614308
__________________
Mooooooooooooo
ulbador is offline   0 Reply With Quote
Old Dec 11, 2011, 01:23 PM   #6
philsown
macrumors newbie
 
Join Date: Jul 2006
It's onclick

It's onclick. I just tested with both onchange and onclick. The one that works is onclick.

<label for="my_check_1" onclick="" > Click my check </label>
<input type="checkbox" name="my_check" id="my_check_1" />

Last edited by philsown; Dec 11, 2011 at 01:24 PM. Reason: Adding code sample
philsown is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Xcode Tag Attribute Nielsenius iPhone/iPad Programming 2 Mar 14, 2014 12:00 PM
html <title> tag doesn't display on webpages? Outburst Mac Basics and Help 1 Jan 20, 2014 01:44 PM
Anyone else notice you can't see your Safari on your Mac tabs in iOS Safari? DramaLLama iOS 7 2 Jan 9, 2014 04:56 PM
TAG / LABEL contact as "Professional Contact"?? luisadastwin iPhone Tips, Help and Troubleshooting 0 Mar 21, 2013 01:44 PM
iPad Mini: App tag in safari issue Thetonyk123 iPad 2 Jan 9, 2013 01:58 PM

Forum Jump

All times are GMT -5. The time now is 02:33 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC