html label don't work in ajax - html

I'm loading html page via Ajax.
Here's the data:
<input type="checkbox" name="dis_net" id="dis_net" value="1" />
<label for="dis_net">Test</label>
But the Label does not work. There is a way to solution.
When I click in the Label checkbox to not put a tick
If we write the other way, it works
<label for="dis_net">Test</label>
<input type="checkbox" name="dis_net" id="dis_net" value="1" />

Other way of labeling:
<label><input type="checkbox" name="myinput" />Test</label>
This way it alway works. I tested your HTML it worked me well, even by loading it with AJAX. What browser do you test it? Strange errors like this can be browser specific.

Related

is there a way to enable a submit button on checked

I'm trying to enable a submit/go-to site button when only one of my checkboxes(any single box) has been checked - can anyone help?
this is the checkbox I'm using
<input type="checkbox" id="number2" name="number2" value="2">
<label for="number2">02 </label>
hope that helps
if you could give me help using HTML and CSS as I don't know how to use scripts that would be great thanks
try it:
<input type="checkbox" id="number2" name="number2" checked />
the checked attribute is for Checkbox Input element, when you use it and open your page, it have to check your checkbox automatic!
You have to use JS, sample:
<input type="checkbox" id="number2" name="number2" value="2" onclick="
if (this.checked)
document.getElementById('SomeSubmitButton').enable = true;
">
I told:
When user clicked on this Checkbox, enable #SomeSubmitButton if that's checked.

why input and label elements got change automatically on development instance

Here is my code
<input class="input-radio" data-pid="${pdict.Product.ID}" type="radio" name="shippingMethod" value="shipToStore" id="ship-shop-${pdict.Product.ID}" />
<label for="ship_to_store">
But when this code goes to develop environment it's reflecting like
<input class="input-radio" data-pid="10775895" type="radio" checked="checked" name="shippingMethod" value="shipToStore" id="ship-shop-10775895" data-ae-form-field="true">
<label for="ship-shop-10775895" class="ae-label">
Can you please help me to find out
From where this data-ae-form-field="true" is coming ?
Why my label for attribute value got change automatically (There is
no js written for this, already checked whole js part).
Why it's adding class to my label class="ae-label"

Site navigation using radio input

Short:
I would like to use input type radio in form as a site navigation tool without need of clicking on submit button. Is this possible?
Explanation:
I am using jQuery Mobile library for my GUI and I like how the look of radio input is automatically changed - In this look I want to classify people according to their names and to switch between pages in long output.
My current code i like this:
<form action="custmers.php" method="post">
<fieldset data-role="controlgroup" data-mini="true" data-type="horizontal">
<input type="radio" name="nav" id="a" value="customers.php?letter=a">
<label for="a">A</label>
:
:
<input type="radio" name="nav" id="z" value="customers.php?letter=z">
<label for="z">Z</label>
</fieldset>
</form>
But except of highlighting currently clicked option the page doesn't redirect.
This might work (haven't tested it)
Its still early in the morning... So there is a chance I'm still tired and not thinking properly. Haha
Change your form to
<form action="customers.php" id="navigation" method="get">
<fieldset data-role="controlgroup" data-mini="true" data-type="horizontal">
<input type="radio" name="letter" id="a" value="a">
<label for="a">A</label>
:
:
<input type="radio" name="letter" id="z" value="z">
<label for="z">Z</label>
</fieldset>
</form>
Then add some jquery to your scripts
$(function(){
var $navigation=$('#navigation');
$navigation.on('change','input[name=letter]',function(){
$navigation.submit();
// or to take a more complicated (read: unneccessary)
// window.location($navigation.attr('action')+'?letter='+$(this).val());
});
});
Do note: you should consider some validation in here. I wont bother mentioning security since you didnt post the rest of your script.

HTML5 Validation Not Trigering

I'm working on making client side validation for inputs.
I had had been using PHP to do it all.
Needless to say things got cluttered very quickly.
So I looked in to JS and HTML5 and want to move in to that system for validation.
The messages I want to show are like this:
I know that these are done with the the <input type="email"> tag.
After some help, I was pointed to this page html5rocks.
However I cant seem to get anything to popup.
I copied code straight from there site and nothing.
<input id="foo" type="number" max="2" value="1" />
<input id="bar" type="number" max="2" value="3" />
<script>
document.getElementById('foo').validity.rangeOverflow; //false
document.getElementById('bar').validity.rangeOverflow; //true
</script>
What am I missing to make the notification appear?
That popup is a new implementation in HTML5. Just create an input field like this:
<input type="email">
The popup appears automatically when the form is submitted if the input isn't an email-address.
More about the new input fields in HTML5 is at W3Schools.
Form must be submitted before validation kicks in.
So you have to add a button with the type of submit so like so:
<input type="submit" value="blah">
And then you have to enclose all the fields/inputs in a <form> and </form> tag.
here is the working code:
<form>
<input id="foo" type="number" max="2" value="1" />
<input id="bar" type="number" max="2" value="3" />
<input type="submit" value="blah">
</form>
<script>
document.getElementById('foo').validity.rangeOverflow; //false
document.getElementById('bar').validity.rangeOverflow; //true
</script>

sticky checkbox

Ii am trying to make a checkbox (to send via email) sticky.
To make sure it doesn't make a problem when sent empty I used the following:
<input type="checkbox" name="something" value="1">
<input type="hidden" name="something" value="0">
I have used things such as:
<input type="checkbox" name="something" value="1" <?=(($_POST['something']=='1')?'checked="checked"':'')?>>
But it does not work.
Can someone please help me? Many thanks Francesco
One could interpret that sticky means that user cannot uncheck the checkbox. That would be achieved using disabled="disabled" attribute.
As a side note, however, it wouldn't be very polite to force people to subscribe to some email list...
Do you mean checked?
If so then it would be
<input type="checkbox" name="something" value="1" checked="checked" />
Hope I understood that correctly