I
i125
Hallo zusammen,
ich hab am Formulardesigner nochmals rumgebastelt.
Nun geht also Folgendes:
Festlegung als Pflichtfeld, dazu mit Fehlererkennung und Rückgabewert
Festlegung ob das Feld editierbar ist.
Definition des Feldes als Datum oder Zahl mit unterschiedlichen eingabewerten.
PHP Code:
Hier der Aufruf:
Lifedemo:
http://www.drei-welten.com/www1/formdemo/forms.php
Download der Scripte:
http://www.drei-welten.com/www1/formdemo/
Copyrights -> Ist mir Latte, es Lebe OpenSource.
Ich bitte mal um Kritik.
Grüße
Alexander Baumann
ich hab am Formulardesigner nochmals rumgebastelt.
Nun geht also Folgendes:
Festlegung als Pflichtfeld, dazu mit Fehlererkennung und Rückgabewert
Festlegung ob das Feld editierbar ist.
Definition des Feldes als Datum oder Zahl mit unterschiedlichen eingabewerten.
PHP Code:
PHP:
function formheader($formname,$workfile){$result = '<form name="'.$formname.'" method="post" action="'.$workfile.'">'; return $result;}
function formfooder(){$result='</form>'; return $result;}
function tableheader(){$result='<table width="400" border="0" cellpadding="0" cellspacing="0">'; return $result;}
function tablefooder(){$result='</table>'; return $result;}
function fieldsetheader($title){$result='<fieldset style="width: 400"><legend>'.$title.'</legend>'; return $result;}
function fieldsetfooder(){$result='</fieldset>'; return $result;}
function standardbuttons(){$result = '<br><input type="submit" name="submit" value="Ok" WIDTH:120px;><input type="reset" name="submit" value="Abbrechen" WIDTH:120px;>';return $result;}
function textfield($primary,$value,$edit,$discription,$tooltip,$type)
{
$charlength="255";
$fieldsize="35";
$errmessage = "";
if($discription<>"")
{
if($edit==false)
{
$editable="readonly";
}
if($primary == true)
{
$color="#FFEAEB";
if(@$_POST[$discription] <> "")
{
$Fieldvalue = $_POST[$discription];
}
else
{
$errmessage = '<a href="#" title="Dies ist ein Pflichfeld. Bitte ausfüllen."><img src="warning.png" width="24" height="24" border="0"></a>';
$Fieldvalue = $_POST[$discription];
$err = true;
}
}
else
{
$Fieldvalue = $_POST[$discription];
$color="#FFFFF";
}
if($type == "int")
{
$output = str_replace(" ", ".", $_POST[$discription]);
$output = str_replace(",", ".", $output);
if(is_numeric($output))
{
$err = true;
$Fieldvalue = $output;
}
else
{
$errmessage = '<a href="#" title="Ihre Eingabe ist keine Zahl."><img src="warning.png" width="24" height="24" border="0"></a>';
}
}
elseif($type == "lower")
{
$output = strtolower($_POST[$discription]);
}
elseif($type == "upper")
{
$output = strtoupper($_POST[$discription]);
}
elseif($type == "date")
{
$searchstr = array(" ","-",".",",","/");
for($i=0;$i<count($searchstr);$i++)
{
$input=explode($searchstr[$i],$_POST[$discription]);
if(count($input)>2)
{
if(strlen($input[1])<2)
{
$input[1]="0".$input[1];
}
if(strlen($input[0])<2)
{
$input[0]="0".$input[0];
}
if(strlen($input[2])==1)
{
$input[2]="200".$input[2];
}
if(strlen($input[2])==2 and $input[2]>20)
{
$input[2]="19".$input[2];
}
elseif (strlen($input[2])==2 and $input[2]<20)
{
$input[2]="20".$input[2];
}
if(checkdate($input[1],$input[0],$input[2]))
{
$output = $input[1].".".$input[0].".".$input[2];
}
else
{
$errmessage = '<a href="#" title="Sie habe ein ungültiges Datum eingegeben."><img src="warning.png" width="24" height="24" border="0"></a>';
}
}
}
if($output <> "")
{}else
{
$errmessage = '<a href="#" title="Sie habe ein ungültiges Datum eingegeben."><img src="warning.png" width="24" height="24" border="0"></a>';
$output = $_POST[$discription];
}
}
elseif($type="text" or $type="")
{
$output = $_POST[$discription];
}
$Fieldvalue = $output;
$style='style="Background-Color : '.$color.'; border-right: #666666 1 solid; border-left: #666666 1 solid; border-top: #666666 1 solid; border-bottom: #666666 1 solid; border-right: #666666 1 solid; border-left: #666666 1 solid; border-top: #666666 1 solid; border-bottom: #666666 1 solid; font-size : 10px"';
$result=array($output,'<tr><td width="200"><a href="#" title="'.$tooltip.'">'.$discription.'</a></td><td><input name="'.$discription.'" type="text" maxlength="'.$charlength.'" id="titel" '.$style.'size="'.$fieldsize.'" value="'.$Fieldvalue.'" '.@$editable.'></td><td>'.$errmessage.'</td></tr>',$err);
}
return $result;
}
Hier der Aufruf:
PHP:
$formname = "Form1"; $workfile="forms.php"; $form = formheader($formname,$workfile); print $form;
$title="Mein Formular"; $form=fieldsetheader($title);print $form;
$form=tableheader(); print $form;
$primary=false; $edit=true; $value="Startwert"; $discription="Vorname"; $tooltip="Tooltip"; $type = "date";
$result=textfield($primary,$value,$edit,$discription,$tooltip, $type); print $result[1];
$form=tablefooder(); print $form;
$form=fieldsetfooder();print $form;
$form=standardbuttons(); print $form;
$form=formfooder(); print $form;
print "<br><br>Wert: ". $result[0];
Lifedemo:
http://www.drei-welten.com/www1/formdemo/forms.php
Download der Scripte:
http://www.drei-welten.com/www1/formdemo/
Copyrights -> Ist mir Latte, es Lebe OpenSource.
Ich bitte mal um Kritik.
Grüße
Alexander Baumann