I know this is a weird question and maybe there are better solutions but in this step of my project it difficult to reform project.
I have some pairs of tags in my html similar to this:
<div>
<label for="first">text</label>
<input id="first" />
</div>
<div>
<label for="second">text</label>
<someTag></someTag>
<input id="second" />
</div>
I intend to generate this html with php, some thing like this code:
<?php
$form = new htmlform('formname');
echo $form->label('text');
echo $form->input('first');
echo $form->label('text');
echo $form->input('first');
?>
here is the problem...
as you see I type input id in second line but labels need that id too.
how can I put text in second line and use that in first line?
any byref or some thing.?.
Can you consider some
labeled_input(id, text)
that generates both, the label and the input?
Related
I have looked everywhere so I apologize if there's an answer to this already, I couldn't find it after hours of searching. Maybe it's not a good way to do it either...
I have a form that has "picks" of a litter, so 1st pick, 2nd pick, 3rd pick, etc. These picks also have genders (Female, Male)
I use a foreach query to grab the available pick spots. If someone isn't assigned to that pick spot, then the input field is enabled for manual typing
Within that foreach query, I need to somehow submit what pick it is and what gender, as well as the typed value, so I can find the pick and store it to the database... The other problem is, it's dynamic where someone may type in 3 input fields, or other times just 1 input field. Basically it'll show 3 input fields and the user can choose to use all 3 or just 1...
No matter what I've tried, it doesn't work. I don't even have my examples because I've tried everything I could find and had to scrap it all
The input, this is for males only but females are the same:
<?php
foreach ($malespickedquery as $pick){
$picktaken=$pick['user_id'];
$pickcustom=$pick['custom_name'];
$pickposition=$pick['pick_id'];
$suffix=ordinal($pickposition);
?>
<div class="form-row pb-3">
<div class="col-12">
<label class="control-label"><?php echo $pickposition.$suffix." Pick "; ?>Male:</label>
<?php if($pickcustom==true){ ?>
<input type="text" name="" class="form-control" value="<?php echo $pickcustom; ?>" />
<?php }elseif($picktaken!="0"){ ?>
<input type="text" name="" class="form-control" value="<?php echo $pick['public_name']; ?>" disabled />
<?php }else{ ?>
<input type="text" name="malepicks[<?php echo $pickposition; ?>][male][]" class="form-control" value="" />
<?php } ?>
</div>
</div>
<?php } ?>
I've tried foreach within foreach, but can never get all information. Most things just return the last input field as well... So if 3 of them are generated, the last input field would come through but not the others. I also did something with foreach where it returned ALL of the fields, even blank ones, which just got confusing and still didn't work right
Thank you in advance!
I want to create a webpage that posts onto itself text inserted into an input field, using CSS to stylize said text once it becomes part of the page. However, I don't know how to refer to it with a CSS selector. I've done what every HTML-newb tries when encountering a problem and wrapped both the form code and PHP statement in classified DIVs, however, the computer visibly doesn't know what I'm trying to address. Likewise, wrapping the PHP statement in paragraph tags doesn't apply to it the stylization said tags are associated with.
For Reference, Form & PHP Code:
<form method = "post">
<textarea name="input"></textarea>
<input type="submit">
</form>
<?php echo $_POST['input'];?>
My apologies if the solution to this is obvious; I can't find information addressing it.
you could inline style it or with a class.
<form method = "post">
<textarea name="input"></textarea>
<input type="submit" name="submit">
</form>
<div class="input-value">
<?php
if(isset($_POST['submit])) {
echo $_POST['input'];
}
?>
</div>
use .input-value class in css
Please try this!
<form method = "post">
<textarea name="input"></textarea>
<input type="submit">
</form>
<?php echo "<div style='color:red;font-family:verdana;font-size:300%'>" .
$_POST['input'] . "</div>" ?>
Are you looking for this? Please let me know! Thanks!
I want to set the value of an input text field with php, but it does not seem to work.
There are many similar Questions where the answer was something like this:
<?php $value = "Show This!" ?>
<form>
<input type="text" name="testname" value="<?php echo $value;?>" >
</form>
But this will print the whole <?php... stuff in the text field like this.
For clarification:. I am expecting to see this.
What am I doing wrong?
Note: I also tried several variants with/without string symbols, also the shorthand variant <input type="text" value="<?=$value?>"> and even something without a php variable:
<form>
<input type="text" name="testname" value="<?php echo 'Show this please';?>" >
</form>
your code looks correct, you just need to run it as PHP instead of HTML
I've a column inside my table to put Html codes, I will use this table for email templating.
I have inside my page, all the templates inside my table, with two buttons, one to remove, and another one to edit.
The edit button shows the code inside a textbox, and to do the preview I did an echo to the code column.
<div class="tempcolumn">
<div><textarea name="ai" rows="15" cols="100" name="code" placeholder="Code">
<?php echo $get_temp; ?></textarea></div>
</div>
Preview
<div class="tempcolumn">
<p><?php echo $get_temp; ?></p>
<div></div>
</div>
To recognize the code and the id i created an hidden input
<input type="hidden" name="temp_id" value="'.$val['template_id'].'">
<input type="hidden" name="temp_code" value="'.$val['text'].'">
The script is working, but when i insert inside the code column some "<" or "=" doesn't work
Is inferfering because it reads the input value like this:
<input type="hidden" name="temp_id" value=" Value here + 'random character that closes the tag' ">
Is there a easier way to do that?
Thanks
You can try;
htmlspecialchars($value)
This will convert html characters to their non-interfering cousins.
See http://docs.php.net/manual/en/function.htmlspecialchars.php as I can't post the equivalents without them becoming characters.
Im trying to make a html form processed in php that outputs to pdf and is print ready.
This is what I have:
A page requesting the categories to include
A page which presents text areas for that categories
A page which displays the final result with an option to print and or make a pdf.
I can make all the information pass along the pages what im lacking is way to display the content properly formatted.
I need this layout:
Text here bold: Description of item
Description of item
(precisely one empty line)
Some more bold text: Description of item
Description of item
and so on.
Im a bit stumbled since the Item descriptions are coming from text areas of which I am able to preserve the line breaks by echoing <.pre> (please excuse the dot, i dont understand how to escape the tag ;) tags along, which end up including all the white space due to the textarea cols.
Assuming I have two textareas and two variables with the titles posting to the last page, how would i go about formatting it properly?
Thank you.
-----EDIT-------
To clarify what I intend:
I have 3 pages:
1 one:
<div class="menu">
Por favor seleccione os conteúdos:
<form name="Categorias" action="Elementos_Descritivos.php" method="post">
<div class="cb-row">
<label for="nome">Nome:</label>
<input id="nome" name="Nome" type="checkbox" value="Nome" checked />
</div>
<div class="cb-row">
<label for="data">Data:</label>
<input id="data" name="Data" type="checkbox" value="Data" checked />
</div>
<div class="cb-row">
<label for="cliente">Cliente:</label>
<input id="cliente" name="Cliente" type="checkbox" value="Cliente" checked />
</div>
<div class="cb-row">
<label for="ob">Observações:</label>
<input id="ob" name="Observacoes" type="checkbox" value="Observacoes" checked />
</div>
<div class="submit">
<input type="submit" value="Seguinte" />
</div>
</form>
</div>
</div>
In this one you choose wich categories go into the doc.
Page 2:
<body>
<?php
$Nome = $_POST["Nome"];
$Data = $_POST["Data"];
$Cliente = $_POST["Cliente"];
$Observacoes = $_POST["Observacoes"];
$Nome1 = "Nome";
$Data1 = "Data";
$Cliente1 = "Cliente";
$Observacoes1 = "Observacoes";
echo "<div class=\"menu2\">
<form name=\"Detalhes\" action=\"Pre_Impressao.php\" method=\"post\">
Por favor preencha os todos os campos em branco:<br/><br/>";
#######################################_NOME_######################################
if ( $Nome == $Nome1 ) {
echo "<div> Nome: <textarea name=\"Nome\" rows=\"6\" cols=\"60\"></textarea></div> <br/>";
}
########################################_DATA_#####################################
if ( $Data == $Data1 ) {
echo "<div> Data: <textarea name=\"Data\" rows=\"6\" cols=\"60\"></textarea></div><br/>";
}
########################################_CLIENTE_##################################
if ( $Cliente == $Cliente1 ) {
echo "<div> Cliente: <textarea name=\"Cliente\" rows=\"6\" cols=\"60\"></textarea></div> <br/>";
}
#######################################_OBSERVACOES_###############################
if ( $Observacoes == $Observacoes1 ) {
echo "<div> Observacoes: <textarea name=\"Observacoes\" rows=\"6\" cols=\"60\"></textarea></div><br/>";
}
####################################################################################
echo "<div class=\"submit\">
<input type=\"submit\" value=\"Seguinte\" />
</div>
</form>
</div>
?>
The second page displays text areas for filling information about hte categories selected in the previous page.
And then page 3, which ought to display the inputs nicely formatted, that's were im stumbled, I know my php is hideous, and i would be better off with a for each loop but for now im trying to focus on getting it done rather than getting it done in a better way :)
If im still not being clear in any aspect please let me clarify so i can improve the post.
Thanks.
You can put PHP code inside normal HTML code (or PDF code), but it might be easier to iterate and generate this way:
If I remember correctly, you can put your data in a table and the formatting will render properly in a PDF. I have also come across the issue that some CSS properties do not render properly in PDF. Hope that helps.