I'm trying to combine two input with same name. One part will be disable but user can see the random value and other part will be given by user.
[<div class="form-group col-md-6">
<label for="ProductCode">Product Code</label>
<input name="prid" type="text\[\]" class="form-control" id="prid" placeholder="Product Code" value="value">
</div>][1]
https://i.imgur.com/CqBHqBk.png
Not sure I understand your question correctly, but it seems to be simple. You can combine two input with same name using "class" html element.
I think according to W3 spec, you're supposed to do
<input type="checkbox" checked="checked" />
And
selected="selected"
But, most browsers will accept it you just write "CHECKED" and don't give it a value. So, what if you do include the attribute, are there any values that would be (consistently) considered false?
There are no values that will cause the checkbox to be unchecked. If the checked attribute exists, the checkbox will be checked regardless of what value you set it to.
<input type="checkbox" checked />
<input type="checkbox" checked="" />
<input type="checkbox" checked="checked" />
<input type="checkbox" checked="unchecked" />
<input type="checkbox" checked="true" />
<input type="checkbox" checked="false" />
<input type="checkbox" checked="on" />
<input type="checkbox" checked="off" />
<input type="checkbox" checked="1" />
<input type="checkbox" checked="0" />
<input type="checkbox" checked="yes" />
<input type="checkbox" checked="no" />
<input type="checkbox" checked="y" />
<input type="checkbox" checked="n" />
Renders everything checked in all modern browsers (FF3.6, Chrome 10, IE8).
The checked and selected attributes are allowed only two values, which are a copy of the attribute name and (from HTML 5 onwards) an empty string. Giving any other value is an error.
If you don't want to set the attribute, then the entire attribute must be omitted.
Note that in HTML 4 you may omit everything except the value. HTML 5 changed this to omit everything except the name (which makes no practical difference).
Thus, the complete (aside from variations in cAsE) set of valid representations of the attribute are:
<input ... checked="checked"> <!-- All versions of HTML / XHTML -->
<input ... checked > <!-- Only HTML 4.01 and earlier -->
<input ... checked > <!-- Only HTML 5 and later -->
<input ... checked="" > <!-- Only HTML 5 and later -->
Documents served as text/html (HTML or XHTML) will be fed through a tag soup parser, and the presence of a checked attribute (with any value) will be treated as "This element should be checked". Thus, while invalid, checked="true", checked="yes", and checked="false" will all trigger the checked state.
I've not had any inclination to find out what error recovery mechanisms are in place for XML parsing mode should a different value be given to the attribute, but I would expect that the legacy of HTML and/or simple error recovery would treat it in the same way: If the attribute is there then the element is checked.
(And all the above applies equally to selected as it does to checked.)
No value is considered false, only the absence of the attribute. There are plenty of invalid values though, and some implementations might consider certain invalid values as false.
HTML5 spec
http://www.w3.org/TR/html5/forms.html#attr-input-checked :
The disabled content attribute is a boolean attribute.
http://www.w3.org/TR/html5/infrastructure.html#boolean-attributes :
The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.
Conclusion
The following are valid, equivalent and true:
<input type="checkbox" checked />
<input type="checkbox" checked="" />
<input type="checkbox" checked="checked" />
<input type="checkbox" checked="ChEcKeD" />
The following are invalid:
<input type="checkbox" checked="0" />
<input type="checkbox" checked="1" />
<input type="checkbox" checked="false" />
<input type="checkbox" checked="true" />
The absence of the attribute is the only valid syntax for false:
<input type="checkbox" />
Recommendation
If you care about writing valid XHTML, use checked="checked", since <input checked> is invalid and other alternatives are less readable. Else, just use <input checked> as it is shorter.
Actually, the HTML 4.01 spec says that these attributes do not require values. I haven't personally encountered a situation where providing a value rendered these controls as unselected.
Here are the respective links to the spec document for selected and checked.
Edit: Firebug renders the checkbox as checked regardless of any values I put in quotes for the checked attribute (including just typing "checked" with no values whatsoever), and IE 8's Developer Tools forces checked="checked". I'm not sure if any similar tools exist for other browsers that might alter the rendered state of a checkbox, however.
The empty string is false as a rule.
Apparently the empty string is not respected as empty in all browsers and the presence of the checked attribute is taken to mean checked. So the entire attribute must either be present or omitted.
checked attribute can be set in the following way in javascript.
(isOrdered stores a boolean value)
<input checked={isOrdered} type="checkbox"/> Ordered
i want to create a textarea, which will store information already inserted into the database and can be updated by a user but everytime i add elements to the query it removes the already inserted data. But when i add elements to the query, it keeps the data intact.
here is the code that keeps the data
<input name="mobile" type="text" class="field span6" rows="6" placeholder="Mobile" value="<?php echo !empty($mobile)?$mobile:'';?>"/>
and here is the code that removes it
<textarea name="mobile" type="text" class="field span6" rows="6" placeholder="Mobile" value="<?php echo !empty($mobile)?$mobile:'';?>"></textarea>
i am really puzzled as to why the textarea elements removes the data, keeping the textarea elements with the data still in tact will be a great help.
Thank you.
You are mis-using the textarea tag. Unlike inputs it requires an opening and closing tag with the value of the textarea defined between the tags rather than through a value attribute.
Try:
<textarea
name="mobile"
class="field span6"
rows="6"
placeholder="Mobile"><?php echo !empty($mobile)?$mobile:'';?></textarea>
Also, unless you're checking the value of $mobile elsewhere, I'd recommend outputting it with htmlentities() to prevent HTML injection.
Good day!
I am having a problem in showing the data that I need to Update.
For example: I have a field - NAME. And user input "John Travolta" on it and enter to save it in SQL. Then to update it, he will click the update and a textbox will appear with the name "John Travolta" with it.
The problem is I am only getting "John" and the "Travolta" does not appear on the text box.
My code is as follows:
<input name="event" type="text" id="event" size="69" value=<?php print stripslashes($row_array['event'])?>>
What can i do in order for the whole name to appear in the textbox?
Thank you in advance.
You need to put quotes before and after the PHP line so HTML can parse it as a string.
otherwise you will end with value=John Travolta when you want value="John Travolta"
Use that code:
<input name="event" type="text" id="event" size="69" value="<?php print stripslashes($row_array['event']);?>">
So I have:
<input type="text" id="keyword" placeholder="placeholder" value="" />
What is the best way to go about defining the value based on the link?
ie.
http://mysite.com/valueplacer?=thisisthevalue
Does this:
<input type="text" id="keyword" placeholder="placeholder" value="thisisthevalue" />
Thanks!
<input type="text" id="keyword" placeholder="placeholder" value="<?php echo htmlspecialchars($_GET['q']); ?>" />
This is assuming that you are going to place a q there in the query string, as the key for the variable. This means the query string will look like
http://mysite.com/valueplacer?q=thisisthevalue
The htmlspecialchars() is for security.
If you actually do want your URL to look like that, you will need to parse $_SERVER['REQUEST_URI'].
I would not recommend doing it like that. Just use GET params as how they were intended.