I have a page that displays some info about a project in a "container", within that container there are some different fields along with 2 buttons that access different pages. I am having an issue getting the buttons to line up horizontally, how can I get this done? I am thinking it has something to do with the way the forms are rendered, is there a better way than forms? can you style forms with css doing like
display: inline
This is the first time I have messed around with HTML, here is my code thanks:
<div class="project-container">
<label class="boldLabel">Project ID:</label>
<span><?php echo $pId; ?></span><br>
<label class="boldLabel">Project Owner:</label>
<span><?php echo $pName; ?></span><br>
<label class="boldLabel">Project Description:</label>
<span><?php echo $pDesc; ?> </span><br><br>
<label class="boldLabel">Project Due Date:</label>
<span><?php echo $dDate; ?> </span><br>
<form action="delete.php" method="GET">
<input type="hidden" name="pId" value="<?php echo $pId; ?>">
<button class="buttonDelete" type="submit" name="delete">Delete Project</button>
</form>
<form action="update.php" method="GET">
<input type="hidden" name="pId" value="<?php echo $pId; ?>">
<input type="hidden" name="pName" value="<?php echo $pName; ?>">
<input type="hidden" name="pDesc" value="<?php echo $pDesc; ?>">
<input type="hidden" name="dDate" value="<?php echo $dDate; ?>">
<button class="buttonUpdate" type="submit" name="update">Update Project</button>
</form>
</div>
</div>
You don't need any 2 forms on your file. You just need 1 general form tag that handles both process (delete and update). These process can be managed throught Javascript functions and events.
Note: The problem about the 2 buttons not being aligned horizontally is because you have certain elements on different form tags. You could do some extra work with css but having 2 forms in one file is normally avoided by developers unless this could be the only way to a certain process.
I fixed the code. You can see the snippet working here:
function buttoncheck(action)
{
//$("project-container").load("process.php", {action: action});
// This is an example of how you could "call" process.php
}
<form action="process.php" method="post">
<div id="project-container" class="project-container">
<label class="boldLabel">Project ID:</label>
<span><?php echo $pId; ?></span><br>
<label class="boldLabel">Project Owner:</label>
<span><?php echo $pName; ?></span><br>
<label class="boldLabel">Project Description:</label>
<span><?php echo $pDesc; ?> </span><br><br>
<label class="boldLabel">Project Due Date:</label>
<span><?php echo $dDate; ?> </span><br>
<input type="hidden" name="pId" value="<?php echo $pId; ?>">
<input type="hidden" name="pId" value="<?php echo $pId; ?>">
<input type="hidden" name="pName" value="<?php echo $pName; ?>">
<input type="hidden" name="pDesc" value="<?php echo $pDesc; ?>">
<input type="hidden" name="dDate" value="<?php echo $dDate; ?>">
<button class="buttonDelete" type="button" name="delete" onClick="buttoncheck(0)">Delete Project</button>
<button class="buttonUpdate" type="button" name="update" onClick="buttoncheck(1)">Update Project</button>
</div>
</form>
And in the "process.php" file
<?php
$action=$_POST['action'];
// To Update
if($action=1){
// update code here
}
if($action=0){
// delete code here
}
You can check how to refresh div content, onclick function, css manage in this links:
Load jquery method
Load Jquery method 2
onclick function
button css design process
Related
How can i change the color of the input box in red if there's an error when i hit the SUBMIT button?
<form method="post" action="" ">
<h3>Add users</h3>
<div class="form-group <?php echo (!empty($error_user) || ($error_taken)) ? 'has-error' : ''; ?>">
<strong>Username: *</strong>
<input type="text" name="username" value="<?php echo $username; ?>" />
<span class="error"><?php echo $error_user; ?></span><br/>
<span class="error"><?php echo $error_taken; ?></span><br/>
</div>
<div class="form-group <?php echo (!empty($error_name)) ? 'has-error' : ''; ?>">
<strong>Name: *</strong>
<input type="text" name="name" value="<?php echo $name; ?>" />
<span class="error"><?php echo $error_name; ?></span> <br/>
</div>
<div class="form-group <?php echo (!empty($error_pass)) ? 'has-error' : ''; ?>">
<strong>Password: *</strong>
<input type="text" name="password" value="<?php echo $password; ?>" />
<span class="error"><?php echo $error_pass; ?></span> <br/>
</div>
<input type="submit" name="submit" value="Add">
</form>
You can use simple CSS
.form-group.has-error input {
border: 1px solid red;
}
You can handle that with javascript or jquery sending POST request with ajax
and before that you can create error handling function
You have two different CSS options.
First use:
.has-error input{
border: 1px solid red;
}
.has-error .error{
color:red;
}
Second:
.has-error>input{
border: 1px solid red;
}
.has-error>.error{
color:red;
}
just apply any of the CSS and you will be fine. The second one will find input and class error just into the class has-error. If there will be another <div> covering them then it will not work.
If you want to live check for errors and display it and change colors etc then you have to use AJAX
I have a form that I'm using within Twitter Bootstrap 3. The form posts data to a mysql database and the placeholder values are echoed from the database. I have used a <textarea> input in the 'bio' field but for some reason the placeholder text behaves differently here. I can't drop a cursor and edit a particular word like I can with the other fields. Why is this?
<div class="form-group">
<form class="" action="" id="edit_profile" method="post">
<label>
Name
</label>
<input id="user_name" name="user_name" type="text" placeholder="<?php echo $user_name ; ?>" value="<?php echo $user_name ; ?>" class="form-control input-md" required="">
</div>
Email
</label>
<input id="user_email" name="user_email" type="text" placeholder="<?php echo $user_email; ?>" value="<?php echo $user_email; ?>" class="form-control input-md" required="">
</div>
Bio
</label>
<textarea style="width:100%" value="<?php echo $bio; ?>" placeholder="<?php echo $bio; ?>" name="bio"></textarea>
</div>
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_session'] ?>">
<button type="submit" class="btn btn-small btn-green pull-right" id="submit">
Save
</button>
</form>
Textarea-text does not go in the value= it goes between the <textarea><?php echo $bio; ?></textarea> tags.
<textarea placeholder="This is a placeholder">This is the actual text</textarea>
You cannot have a value= on a <textarea> since it will stay the same regardless of what you put inside the <textarea> and therefore won't change anything regardless of what you type. (Try removing the "This is the actual text" in the example)
We have form page like this:
We wanted to make design like this:
Means:
Name & email and their text field should display as like above image.
Message & its box should display like comment section.
Same result need for Name & email present below.
Need space between 2 button present in bottom.
css
media only screen and (min-width: 1224px)
.send-friend h2 {
text-align: center;
}
#media only screen and (min-width: 1224px)
form .legend {
border: none;
color: #000;
font-family: 'Roboto Condensed', sans-serif;
font-size: 13px;
font-style: normal;
font-weight: bold;
line-height: 1.4;
margin: 0 0 15px;
padding-bottom: 7px;
text-rendering: optimizespeed;
text-transform: uppercase;
}
}
html
<div class="send-friend">
<?php
echo $this->getMessagesBlock()->toHtml();
?>
<div class="page-title">
<h1><?php
echo $this->__('Email to a Friend');
?></h1>
</div>
<form action="<?php
echo $this->getSendUrl();
?>" method="post" id="product_sendtofriend_form">
<div class="fieldset">
<?php
echo $this->getBlockHtml('formkey');
?>
<h2 class="legend"><?php
echo $this->__('Sender Details');
?></h2>
<ul class="form-list" id="sender_options">
<li class="fields">
<div class="field">
<label for="sender_name" class="required"><em>*</em><?php
echo $this->__('Name:');
?></label>
<div class="input-box">
<input name="sender[name]" value="<?php
echo $this->escapeHtml($this->getUserName());
?>" title="<?php
echo $this->quoteEscape($this->__('Name'));
?>" id="sender_name" type="text" class="input-text required-entry" />
</div>
</div>
<div class="field">
<label for="sender_email" class="required"><em>*</em><?php
echo $this->__('Email:');
?></label>
<div class="input-box">
<input name="sender[email]" value="<?php
echo $this->escapeHtml($this->getEmail());
?>" title="<?php
echo $this->quoteEscape($this->__('Email Address'));
?>" id="sender_email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" class="input-text required-entry validate-email" />
</div>
</div>
</li>
<li class="wide">
<label for="sender_message" class="required"><em>*</em><?php
echo $this->__('Message:');
?></label>
<div class="input-box">
<textarea name="sender[message]" class="input-text required-entry" id="sender_message" cols="3" rows="3"><?php
echo $this->escapeHtml($this->getMessage());
?></textarea>
</div>
</li>
</ul>
</div>
<div class="fieldset">
<h2 class="legend"><?php
echo $this->__('Recipient Details');
?></h2>
<ul class="form-list" id="recipients_options">
<li class="fields">
<div class="field">
<label for="recipients_name" class="required"><em>*</em><?php
echo $this->__('Name:');
?></label>
<div class="input-box">
<input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name" />
</div>
</div>
<div class="field">
<label for="recipients_email" class="required"><em>*</em><?php
echo $this->__('Email Address:');
?></label>
<div class="input-box">
<input name="recipients[email][]" value="" title="<?php
echo $this->quoteEscape($this->__('Email Address'));
?>" id="recipients_email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" class="input-text required-entry validate-email" />
</div>
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<p class="back-link"><a href="#" onclick="history.back(); return false;"><small>« </small><?php
echo $this->__('Back');
?></a></p>
<button type="submit" class="button<?php
if (!$this->canSend()):
?> disabled<?php
endif;
?>"<?php
if (!$this->canSend()):
?> disabled="disabled"<?php
endif;
?>><span><span><?php
echo $this->__('Send Email');
?></span></span></button>
<div id="max_recipient_message" style="display:none;">
<?php
if ($this->getMaxRecipients()):
?>
<p class="limit"><?php
echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients());
?></p>
<?php
endif;
?>
</div>
<?php
if (1 < $this->getMaxRecipients()):
?>
<p id="add_recipient_button">
<button type="button" onclick="add_recipient();" class="button"><span><span><?php
echo $this->__('Add Recipient');
?></span></span></button>
</p>
<?php
endif;
?>
</form>
</div>
Maybe you could try to put the form in a <div> and then increase the width of the input boxes.
Do put padding to leave some white space for aesthetic purpose :)
Example <input type="text" id="text" name="text_name" style="width: 300px;" />
(if you are not considering responsiveness)
I would prefer if you use .text{max-width:110%;}
Since you are new to CSS, the previous CSS shown can be used for multiple ids by putting a comma and the respective tags you would like the following css to apply.
Then for the words indicating which textbox is what, you could use a text-align:left
You can use bootstrap class text-center to set alignment in center position.
How to set focus the focus to a specific form input
<? foreach($words as $word): ?>
<form data-word="<? print $word['Word']['en_words'] ?>">
<input autofocus type="text"/>
<input type="submit" value="Check"/>
</form>
<? endforeach; ?>
I'm creating a register form which requires a 'check if username available' button.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div id="availablity">
<input type="text" name="name" value="<?php _e("Username") ?>" style="float: left;"/>
<span id="availability_status" style="float: left;">icon here</span>
<input type="submit" name="check" value="<?php _e("Check") ?>" style="float: left;"/>
<div style="clear: both;"
</div>
<input type="text" name="mail" value="<?php _e("E-Mail") ?>" id="" class="input" />
<input type="submit" value="<?php _e("Register") ?>" id="register" />
<p class="statement"><?php _e("A password will be e-mailed to you.") ?></p>
</form>
The button, on line 5, contains text that is translatable, hence the value will change. The code works, when 'Check' is clicked an extra query named 'check' is submitted, and clicking 'Submit' the 'check' is disregarded. Is there any way I can change the text while keeping a default value (possibly '1'). Currently, all I can do server side is check if a query named 'check' was submitted and not bother with it's value.
Instead of an <input>, where the value is exactly the same as the text on the screen, use a <button> where the text on the screen can be anything you want.
In other words, change
<input type="submit" name="check" value="<?php _e("Check") ?>"
style="float: left;"/>
to
<button type="submit" name="check" value="1" style="float: left;">
<?php _e("Check") ?>
</button>
so that it will always have the value 1, no matter the text! (Of course you can use whatever value you want.)