I want to restrict date input in my form. I'm using PHP and HTML to code.
<?php
echo '<input type="date" name="doc" value="' . date("d-m-Y") . '" min="11-05-2014" max="' . date("d-m-Y") . '"/>';
?>
I've tried this post. It has a solution using jQuery, but I don't want to use jQuery.
<?php
echo '<input type="date" name="doc" value="' . date("Y-m-d") . '" min="2014-11-04" max="' . date("Y-m-d") . '"/>';
?>
Related
I am creating a database front end that will populate a table with the records in a the db, putting all values into input boxes so that they can be changed. I want to be able to make changes and have it update just that specific record.
This is what I currently have.
{
if($row["order_number"]===NULL)
{
$on='<input type="number" name="orderNo" />';
} else {$on='<input type="number" name="orderNo" value="'. $row["order_number"] . '" />';}
if($row["name"]===NULL)
{
$cn='<input type="text" name="cusName" />';
}else {$cn='<input type="text" name="cusName" value="'. $row["name"] . '" />';}
if($row["product_type"]===NULL)
{
$pt='<input type="text" name="prodType" />';
} else {$pt='<input type="text" name="prodType" value="'. $row["product_type"] . '" />';}
$id='<input type="number" name="orderID" value="'.$row["order_id"].'"/>';
$tableCode.='<tr><td>' . $on . '</td><td>' . $cn . '</td><td>' . $pt . '</td><td><input type="submit" value="Update" name="'. $row["order_id"]. '" /></td><td hidden>'.$id.'</td></tr>';
}
This code is looped for all results in the table. samples.html.php simply sticks the results in some table tags on a webpage, along with the headers. The order_id is the primary key of the table (actually 2 tables, but I know how to handle that side of it)
Any help in this would be appreciated! Thanks!
OK, as promised, here is what I came up with. Mignt not be the best way, but it seems to work for my relatively small application.
while($row = mysqli_fetch_assoc($result))
{
$on='';
$cn='';
$pt='';
$id='';
if($row["order_number"]===NULL)
{
$on='<input type="number" name="orderNo" />';
} else {$on='<input type="number" name="orderNo" value="'. $row["order_number"] . '" />';}
if($row["name"]===NULL)
{
$cn='<input type="text" name="cusName" />';
}else {$cn='<input type="text" name="cusName" value="'. $row["name"] . '" />';}
if($row["product_type"]===NULL)
{
$pt='<input type="text" name="prodType" />';
} else {$pt='<input type="text" name="prodType" value="'. $row["product_type"] . '" />';}
$id='<input type="number" name="orderID" value="'.$row["order_id"].'"/>';
$tableCode.='<form class="tr" action="?" method="post"><span class="td">' . $on . '</span><span class="td">' . $cn . '</span><span class="td">' . $pt . '</span><span class="td"><input type="submit" value="Update" name="Update" /></span><span hidden class="td_hidden">'.$id.'</span></form>';
}
This way, only the values from the form that I used get submitted, so only that row is updated. I used CSS display:table styling to get it to look like a table, similar to the third answer of this question.
Thanks everyone for their willingness to help! If anyone has ideas for improvements, I am open to them.
I have something like this in my code:
<?php
foreach ($tomb2[1] as $key => $metaname){
$talalat = $tomb[1][$key];
echo '<p>' . "$metaname\n" . '</p>' . '<br>' . '<input type="text" name="metavalue[]" value="' . "$talalat\n" . '">' . '<br>';
}
?>
<input type="submit" name="Generálás" value="insert" onclick="insert()" />
</form>
I try to echo the several different values, however I get only the last one. Possibly the array contains only the last one. What am I doing wrong?
if you use a post method in form then you have to written $ertekek = $_POST["metavalue"] instead of $_GET["metavalue"] and then use print_r($ertekek)
instead of echo $ertekek;
You have written $talalat = $tomb[1][$key]; instead of $talalat = $tomb2[1][$key];
I have an XML file with the following content:
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="ALALALAL"><vt:lpwstr>asdasda</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="MACABSZ"><vt:lpwstr>ooooo</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="4" name="3"><vt:lpwstr>c</vt:lpwstr></property><property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="5" name="4"><vt:lpwstr>d</vt:lpwstr></property>
I have the following php. (I am able to fine desired parts of the xml):
if (preg_match_all ('_name="(.*?)"_', $ekker, $tomb2));
if (preg_match_all ('_<vt:lpwstr>(.*?)</vt:lpwstr>_', $ekker, $tomb));
In an html file I want to echo the results, so I use this:
<form>
<?php
foreach ($tomb2[1] as $metaname);
foreach ($tomb[1] as $talalat){
echo '<p>' . "$metaname\n" . '</p>' . '<br>' . '<input type="text" name="firstname" value="' . "$talalat\n" . '">' . '<br>';}?>
</form>
As a result I get this:
However this is not exactly what I want. Instead of the first three "4" I need: ALALALAL, MACABSZ, 3. Why does it echo only the last result of the 'name="(.*?)"' search?
Thanks for your answer!
From what I get, what you want is to access both arrays items with same index in one single loop. Maybe this will do :
<form>
<?php
foreach ($tomb2[1] as $key => $metaname){
$talalat = $tomb[1][$key];
echo '<p>' . "$metaname\n" . '</p>' . '<br>' . '<input type="text" name="firstname" value="' . "$talalat\n" . '">' . '<br>';
}
?>
</form>
I have proxy server powered on PHProxy 0.5b2 where is included mini url form. But there is an problem with CSS. Every visited page overwrite and overlap my own CSS.
I tried to add own style="" for every object but is not working (visited sites overwrite css).
My index.inc.php
if ($_flags['include_form'] && !isset($_GET['nf']))
{
$_url_form = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
. '<form method="post" action="' . $_script_url . '">'
. ' <label for="____' . $_config['url_var_name'] . '">Address:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
. ' <input type="submit" name="go" value="Go" />'
. ' [go: up one dir, main page]'
. '<br /><hr />';
foreach ($_flags as $flag_name => $flag_value)
{
if (!$_frozen_flags[$flag_name])
{
$_url_form .= '<label><input type="checkbox" name="' . $_config['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' /> ' . $_labels[$flag_name][0] . '</label> ';
}
}
$_url_form .= '</form></div>';
$_response_body = preg_replace('#\<\s*body(.*?)\>#si', "$0\n$_url_form" , $_response_body, 1);
}
Any help?
Thanks
Peter
with this piece of code
$feOnline = New Zend_Form_Element_Radio('online');
$feOnline->setValue($article->online)
->addMultiOptions(array(0=>'offline', 1=>'online'))
->setLabel('Online');
this html is generated
<dd id="online-element">
<label for="online-0">
<input type="radio" checked="checked" value="0" id="online-0" name="online">offline
</label><br>
<label for="online-1"><input type="radio" value="1" id="online-1" name="online">online
</label>
</dd>
However I don't want the input-tag inside the label-tag. No need for the "" either...
What decorators must I add to get this output?
<dd id="online-element">
<input type="radio" checked="checked" value="0" id="online-0" name="online"><label for="online-0">offline</label>
<input type="radio" value="1" id="online-1" name="online"><label for="online-1">online</label>
</dd>
If you are using default Zend_View_Helper_FormRadio you can't change the way radio is rendered.
The code is as follows (line 159)
// Wrap the radios in labels
$radio = '<label'
. $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">'
. (('prepend' == $labelPlacement) ? $opt_label : '')
. '<input type="' . $this->_inputType . '"'
. ' name="' . $name . '"'
. ' id="' . $optId . '"'
. ' value="' . $this->view->escape($opt_value) . '"'
. $checked
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag
. (('append' == $labelPlacement) ? $opt_label : '')
. '</label>';
No configuration is in place to change the logic.
Think of the reason why you REALLY need to change the way it is rendered, try using CSS to style the output for example.
If you conclude, you need to change rendering, create your own view helper and use it instead of the default one.