I am trying to add search image inside search box with form element.
My code is
<div class="col-xs-9">
<form action="search">
<input class="form-control" type="search" />
<span class="glyphicon glyphicon-search"></span>
<button type="submit" class="btn"><i class="glyphicon glyphicon-search"></i>
</button>
</form>
</div>
I want when user click on the search image inside search box form action should call
code is http://jsfiddle.net/chetfarley/WK3Q6/1/
Trying code from https://stackoverflow.com/a/19918345/876739
You can do it like this:
HTML:
<div class="col-xs-9">
<input class="form-control" type="search" />
<button type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
CSS:
.form-control + button {
position: absolute;
right: 20px;
top: 7px;
border: 0;
background-color: transparent;
box-shadow: none;
}
And a little event listener, you won't need if you just want the form to be submited:
document.getElementsByTagName("button")[0].addEventListener("click", function(){
alert("doing");
});
Here is the demo: http://jsfiddle.net/WK3Q6/275/
Related
Here is the code. There is a search bar where a user can put in a topic then select a button that shows different categories.
<form action="search.php" method="GET">
<i class="fas fa-search" aria-hidden="true"></i>
<input placeholder="Search" name="search" aria-label="Search">
<input type="submit" value="S" class="searchButton" name="submit-request"/>
<div class="buttons" style="text-align:center;">
<input type="button" class="spec" name="category1" value="category1">
<input type="button" class="spec" name="category2" value="category2">
<input type="button" class="spec" name="category3" value="category3">
<input type="button" class="spec" name="category4" value="category4">
<input type="button" class="spec" name="category5" value="category5">
</div>
</form>
This search form works perfectly fine with checkboxes. What should I do as an alternative? Is there a way I can style the checkboxes as buttons. If they are checkboxes how can I make it so that a user can only pick one category.
Use radio buttons.
Show name for radio with label.
To style a radio button, hide it, and add pseudo element.
<button> is it's own tag.
<button class="spec" name="category5">category5</button>
If you wanted to use CSS (you didn't tag it in your post), you can try this:
https://www.w3schools.com/css/tryit.asp?filename=trycss_form_button
<div class="navigation">
<input type="checkbox" class="navigation__checkbox" id="**navi-toggle**">
<label for="**navi-toggle**" class="navigation__button">
<span class="navigation__icon"> </span>
</label>
</div>
.navigation {
&__checkbox {
display: none;
}
&__button{
background-color: $color-white;
height: 7rem;
width: 7rem;
}
You say that you want to be able to still use checkbox as that is what functions... Well you could do so and use a label that is linked to that checkbox, and then simply style your label as your button.
I do not know what I've done wrong, this works perfectly on the index page with of course another code, something smaller, but the form submits there.
Here I am trying to make a modal with a form, the form will be used to create a new article but the submit button isn't working, nothing is happening when it gets pressed. I really don't know whats wrong with it.
Code:
<div class="modal fade" id="createArticle" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Create a new article</h4>
<small style="color:orange">Please add only important articles to the quick links</small>
</div>
<div class="modal-body">
<form onsubmit="return validate();" action="" method="post">
<div class="form-group">
<label for="createArticleTitle">Title:</label>
<input type="input" class="form-control" id="createArticleTitle" name="createArticleTitle" maxlength="250" placeholder="Insert Article Title...">
</div>
<!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title">Article Message:<br>
<small><u>Text Formatting</u><br><br>
Use <code>[center] Your text here [/center]</code> to center your message.<br>
Use <code>[b] Your text here [/b]</code> to make your message <strong>bold</strong>.<br>
Use <code>[i] Your text here [/i]</code> to to make your message <i>italic</i>.<br>
Use <code>[u] Your text here [/u]</code> to underline your message.<br>
Use <code>[img] img url here [/img]</code> to insert a image.<br>
Use <code>[rigt/left] Your text here [/right/left]</code> to align your message on the right or on the left.<br>
Use <code>[ul] Your text here [/ul]</code> for a unordered list, use <code>[*]</code> to add items.<br>
Example: <code>[ul][*] Apple[/ul]</code> - dotes<br>
Example: <code>[ol][*] Apple[/ol]</code> - numbers<br><br>
Use <code>[quote] Your text here [/quote]</code> to add a quote.<br>
Use <code>[url=link] Your url title here [/url]</code> to insert a url.<br>
Use <code>[code] Your code here [/code]</code> to insert code.</small>
</h3>
<!-- tools box -->
<div class="pull-right box-tools">
<button type="button" class="btn btn-default btn-sm" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button>
</div>
<!-- /. tools -->
</div>
<!-- /.box-header -->
<div class="box-body pad">
<form>
<textarea class="textarea" placeholder="Insert the article here..." id="createArticleMes" name="createArticleMes" maxlength="10000" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
</form>
</div>
<br>
<div class="custom-controls-stacked">
<label for="createArticleQuick">Do you want to show this article to the Quick Links in the footer?</label>
<br>
<label class="custom-control custom-radio">
<input id="createArticleQuick" name="createArticleQuick" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Yes</span>
</label>
</div>
</div>
<button type="submit" name="createArticleButton" class="btn btn-default">Create</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Here is the function too:
<script>
function validate(){
var n1 = document.getElementById("createArticleTitle");
var n2 = document.getElementById("createArticleMes");
if(n1.value != "" && n2.value != ""){
return true;
}
alert("You must add a title and a message atleast.");
return false;
}
</script>
Instead of using <form> tag without any attributes try using something like this
<form action="welcome.php" method="post">
The issue was that I was using twice
<div class="box-body pad">
<form>
<textarea class="textarea" placeholder="Insert the article here..." id="createArticleMes" name="createArticleMes" maxlength="10000" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
</form>
</div>
I am trying to get a custom input style have a glyph icon inside and have a button on the right that says go.
Here is my js fiddle with it. jsfiddle
<div class="form-group">
<div class="icon-addon addon-sm">
<input type="text" placeholder="Search All Orders" class="form-control" id="Order Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
</div>
</div>
The problem i am having is when i try to add the button on the right it makes the icon disappear when the input is clicked.
Using your fiddle I simply added an absolutely positioned button into your search box. Perhaps this is what you were looking for?
Added button in HTML:
<input type="text" placeholder="Search All Orders" class="form-control" id="Order Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
<button class="button-go">go</button>
Button's CSS:
.button-go {
position: absolute;
right: 0;
top: 0;
height: 30px;
}
https://jsfiddle.net/t6295xrd/
Here is a Demo for what i understood from you i just add the button to your fiddle and add this css to position it on right.
#Order_Search {
padding-right:20px;
}
.go-btn {
position: absolute;
right: 3px;
margin-left: -2.5px;
top: 2px
}
and this is the html
<div class="form-group">
<div class="icon-addon addon-sm">
<input type="text" placeholder="Search All Orders" class="form-control" id="Order_Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
<button class="go-btn"> Go </button>
</div>
I've created a search form using bootstrap. I've also used jquery to generate a delete search button (x) when text is input, however, I am stuck trying to get it on the same line as the search form (ideally in the box to the right).
As you can see in the second picture, when "1" is entered into the form the button is generated below the search form. I have included my code below, any help would be greatly appreciated.
<form id="PWFS">
<label for="Label">Info</label>
<button type="button" class="btn btn-link btn-xs"<i class="fa fa-question-circle fa-lg"></i></button>
<div class="row">
<div class="col-md-8">
<div class="input-group btn-group">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
<input type="text" class="form-control search" id="search" placeholder="Workflow #">
<span id="searchclear" class="searchclear fa fa-times"></span>
</div>
</div>
<button id="WFFsearch" type="submit">Search</button>
</div>
</form>
</div>
<br>
CSS
.searchclear {
position: relative;
z-index: 10;
right: 5px;
top: 0;
bottom: 0;
height: 14px;
margin: auto;
font-size: 14px;
cursor: pointer;
color: #ccc;
}
Thank you Lal, Phil and adamdc78. I just had to change the position to absolute.
I'm trying to position a clear button inside an input field, at the right before to the search icon, however it's not working; the "x" is displayed in front of the input field instead.
i use absolute positioning with right:0 and top:4px
You can see my example here: http://www.bootply.com/YUwdJ5Kvx6
A little update to get what you want:
input {
/* Avoid use typing under the clear button. */
padding-right: 30px !important;
}
.input-group-btn {
position: relative;
/* This avoid the "clear" button being hidden while
the input has focus on. */
z-index: 1000;
}
.input-group-btn a.btn {
position: absolute;
right: 38px;
top: 0px;
}
/* This avoid the bad effect when clicking the button. */
.input-group-btn a.btn:hover,
.input-group-btn a.btn:active {
box-shadow: none;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css" rel="stylesheet"/>
<div style="width: 300px;">
<div class="input-group">
<input class="form-control" placeholder="Search by ID..." type="text">
<span class="input-group-btn">
<a class="btn" style="color: rgb(204, 204, 204); text-decoration: none; " href="#clear">
<i class="glyphicon glyphicon-remove"></i>
</a>
<button type="submit" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
I added position: relative to input-group-btn for position: absolute to work on the close button. Then just a negative right: 36px to move the button in the input field.
I put the close button inside the input-group-btn because it was easier for me, and it automatically takes care of the vertical alignment of your button (I just added the btn class to the a tag).
I added padding-left: 30px !important to the input field to avoid user typing under the x button. To have a symmetrical space, you would need 38px, but it looks a bit much... You can change this value at your discretion to get the result you want.
Since the a tag is inside the input-btn-group with the btn class, you need something like a:hover { box-shadow: none ; } to avoid ugly box-shadow in your input when clicking on the close button.
Try this i have appended the button before and after. Comment if this is you want or not. Did i understood you correct?
<form action="#" method="get" class="sidebar-form" id="id_search" style="width:300px;margin-left:100px;margin-top:100px;">
<div class="input-group double-input">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="glyphicon glyphicon-remove"></span>
</button>
</span>
<input type="text" placeholder="Second" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="glyphicon glyphicon-remove"></span>
</button>
</span>
</div><!-- /input-group -->
</form>