Text in first field shows as label for second field - php

How do we make a text field sync with another text field i.e Adding text in first field shows as label for another text field.Basically i have made a currency exchange skeleton.
<form method='POST' action='index.php'>
<div class="row uniform 50%">
<div class="6u 12u(mobilep)">
<input type="text" name="from" value="" placeholder="From Which Currency?" tabindex="1" />
<input type="hidden" name="owner" value="<?php echo $username; ?>" />
</div>
<div class="6u 12u(mobilep)">
<input type="text" name="to" value="" placeholder="To Which Currency?" tabindex="2" />
</div>
</div>
<div class="row uniform 50%">
<div class="6u 12u(mobilep)">
<input type="text" name="limit" value="" placeholder="How much volume?" tabindex="3" />
</div>
<div class="6u 12u(mobilep)">
<input type="text" name="fee" value="" placeholder="Your Fee or put Zero(Don't add %age sign)" tabindex="4" />
</div>
<div class="6u 12u(mobilep)">
<input type="text" name="price" value="" placeholder="Your Rate ( Don't add symbols)" tabindex="4" />
</div>
</div>
This is the result i currently see with this code: http://i.imgur.com/dWD3Nu5.png
But i want to make it like this: http://i.imgur.com/34BU8g3.png

Add text of your textbox to label on the keyUp event of that textbox itself.

Related

Issue populating textarea with db data

So, like the title said, i'm having an issue while i'm populating a text area that is being used on HTML form, because it is not getting any content in it.
this is the form with the php while.
<?php
while ($row = mysqli_fetch_array($query))
{ echo '
<form action="insert/insertReport.php" id="newReport" method="post">
<div class="form-group">
<label for="clientRep">Cliente</label>
<br>
<input type="text" name="client" class="form-control" id="client" value="'.$row['client'].'">
</div>
<div class="form-group">
<label for="titleRep">Título do Relatório</label>
<br>
<input type="text" name="title" class="form-control" id="title" value="'.$row['title'].'">
</div>
<div class="form-group">
<label for="namefat">Data</label>
<br>
<input type="text" name="date" class="form-control" id="date" value="'.$row['date'].'">
</div>
<div class="form-group">
<label for="localRep">Local</label>
<br>
<input type="text" name="local" class="form-control" id="local" value="'.$row['local'].'">
</div>
<div class="form-group">
<label for="reportRep">Relatório</label>
<br>
<textarea rows="12" name="report" class="form-control" id="report" form="newReport" value="'.$row['report'].'"></textarea>
</div>
<input type="hidden" name="id" class="form-control" id="id" value="'.$row['id'].'">';
}?>
And this is the php query.
$sql = 'SELECT * FROM reports'
Does anyone know what's wrong with it?
Text area does not accept a value attribute. You place the contents between the textarea tags:
<textarea rows="12" name="report" class="form-control" id="report" form="newReport">'.$row['report'].'</textarea>

PHP - dynamic fields array not

I have a form with dynamic fields. When I add a dynamic field and do a var_dump of that field, I am getting only the first result.
Form:
<div class="form-group halltype">
<label class="col-sm-2 col-sm-2 control-label">HallType</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="title1[]" placeholder="Main Title"><br />
<input type="text" class="form-control" name="title2[]" placeholder="Title 2"><br />
<input type="text" class="form-control" name="seating[]" placeholder="Seating Capacity"><br />
<input type="text" class="form-control" name="floating[]" placeholder="Floating Capacity"><br />
</div>
</div>
<div class="form-group addhalltype">
<label class="col-sm-2 col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="button" class="btn btn-info" id="">Add Hall Type</button>
</div>
Jquery:
$(".addhalltype").click(function() {
$halltype = '<div class="form-group halltype"><label class="col-sm-2 col-sm-2 control-label">HallType</label><div class="col-sm-10"><input type="text" class="form-control" name="title1[]" placeholder="Main Title"><br /><input type="text" class="form-control" name="title2[]" placeholder="Title 2"><br /><input type="text" class="form-control" name="seating[]" placeholder="Seating Capacity"><br /><input type="text" class="form-control" name="floating[]" placeholder="Floating Capacity"><br /></div></div>';
$($halltype).insertBefore(".addhalltype");
});
and if I do var_dump($_POST['title1']), I get
array(1) {
[0]=>
string(4) "1212"
}
you are printing $_POST['title1'] in var_dump it will show you only value that u inserted for name="title1[]".
Here you are using dynamic array but with different name ie name equal to title1[] title1[] seating[] and floating[].
if you want to get all the post values in one name like title[0],title[1],...title[n] to get the result in this format you have to write your above code with this format.
<input type="text" class="form-control" name="title[]" placeholder="Main Title"><br />
<input type="text" class="form-control" name="title[]" placeholder="Title 2"><br />
<input type="text" class="form-control" name="title[]" placeholder="Seating Capacity"><br />
<input type="text" class="form-control" name="title[]" placeholder="Floating Capacity"><br />

Submit button not working. No action is taken when i click on the create account button

This is the form on whic i'm working. i want it to send the data to 1.php but when i click on the create account button. please tell what is wrong with this code.
<div class="logmod__form">
<form accept-charset="utf-8" action="1.php" class="simform" method="post">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-name">Email*</label>
<input class="string optional" maxlength="255" id="user-email" placeholder="Email" type="email" size="50" />
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw">Password *</label>
<input class="string optional" maxlength="255" id="user-pw" placeholder="Password" type="text" size="50" />
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat">Repeat password *</label>
<input class="string optional" maxlength="255" id="user-pw-repeat" placeholder="Repeat password" type="text" size="50" />
</div>
</div>
<div class="simform__actions">
<input class="sumbit" name="commit" type="sumbit" value="Create Account" />
<span class="simform__actions-sidetext">By creating an account you agree to our <a class="special" href="#" target="_blank" role="link">Terms & Privacy</a></span> </div>
</form>
</div>
Correct it in your button
type="submit"
You missed name Attribute in your fields without it nothing is submitted
<input class="string optional" maxlength="255" id="user-pw-repeat" placeholder="Repeat password" type="text" size="50" name="user-pw-repeat"/>

html5 input date empty on post php

I'm using the HTML5 input date type. After posting, I see this input empty, and all the other inputs (HTML4 types) are OK.
What could be the reason?
This is my form:
<form action="/SGM/index.php?r=manager/addcoach_post" method="post">
<div class="registerFeildArea2">
<div class="registerTxtP2">Family name</div>
<div class="registerFeild">
<input name="lname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">First name</div>
<div class="registerFeild">
<input name="fname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Address</div>
<div class="registerFeild">
<input name="address" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">City</div>
<div class="registerFeild">
<input name="city" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Birthdate</div>
<div class="birthDayFeild">
<input name="bdate" id="meeting" type="date" value="2011-01-13"/>
</div>
</div>
<div class="AddBtn"><input name="Next" type="submit" value="הוסף" class="AddBtnValue" /></div>
</form>
And when I get to the actionAddcoach_post(), all the fields are OK except for the bdate.
What could be the reason?

Modx css issue not pulling in styles on the form

I'm editing a site using Modx cms.
I'm trying to add a contact form to the contact page. I already have one in the sidebar specified in a template. The code on the contact page form points to the same div tags, but it isn't picking up any of the css.
any ideas why this is happening. Do I need some kind of plugin?
Thanks for all your help
Regards
Judi
<div class="enquiry-form-top">
<h2>Enquiry Form</h2>
</div>
<div class="enquiry-form">
<form class="enquiry" id="enquiry" action="mailer.php" method="post">
<fieldset>
<legend>Enquiry Form</legend>
<div class="form-field">
<label for="Name">Name:</label>
<input type="text" id="Name" name="Name" value="">
</div>
<input type="hidden" name="thankspage" value="thank-you.html">
<input type="hidden" name="subject" value="Enquiry Form">
<div class="form-field">
<label for="Address"> Address:</label>
<input type="text" id="Address" name="Address" value="">
<input type="text" id="Address2" name="Address2" value="">
<input type="text" id="Address3" name="Address3" value="">
</div>
<div class="form-field">
<label for="DOB">DOB:</label>
<input id="DOB" type="text" name="DOB" value="" />
</div>
<div class="form-field">
<label for="Total-Fund-Size">Total Fund Size:</label>
<input id="Total-Fund-Size" type="text" name="Total-Fund-Size" value="" />
</div>
<div class="form-field">
<label for="Number-Of-Funds">Number Of Funds:</label>
<input id="Number-Of-Funds" type="text" name="Number-Of-Funds" value="" />
</div>
<div class="form-field">
<label for="Lump-Sum-Benefit">Has Lump Sum <br/>Benefit Been Taken:</label>
<ul>
<li>Yes <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit" value="Yes" /></li>
<li>No <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit2" value="No" /></li>
</ul>
</div>
<div class="form-field">
<label for="Telephone-Number">Telephone Number:</label>
<input type="text" id="Telephone-Number" name="Telephone-Number" value="">
</div>
<div class="form-field">
<label for="Best-Time-To-Contact">Best Time To Contact:</label>
<input type="text" id="Best-Time-To-Contact" name="Best-Time-To-Contact" value="">
</div>
<div class="form-field">
<label for="Email">Email:</label>
<input type="text" id="Email" name="Email" value="">
</div>
<div class="form-field">
<img src="CaptchaSecurityImages.php" alt="">
<label for="security_code"> Security Code: </label>
<input type="text" id="security_code" name="security_code">
</div>
<div class="form-buttons">
<input type="image" name="Submit" value="Submit" src="images/annuity/submit_button.gif">
</div>
</fieldset>
</form>
There is no reason I can think of for this to happen, and you don't need any plug-ins.
Once the page is rendered it is of course just HTML and it doesn't matter if it was made in modx or any other system.
Can you investigate the page using Firebug and make sure the Stylesheet is loading?
Maybe the form that is working is enclosed in a div with a class and all the styles are set in the style sheet as follows (ie. Children of the containing div)
.enclosingdiv .form-field
That would explain why your form isn't picking up the styles.
Also you should check out eform (Package, wiki) it's great for simple contact forms.

Categories