Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to create a text input with an attached button

Tags:

kendo-ui

I'm trying to create a textbox with an attached button that looks similar to a Kendo DatePicker or NumericTextBox. This is close, but it doesn't quite line up. Any help straightening this up would be appreciated.

<style>
    .unselectable
    {
        -moz-user-select: -moz-none;
        -khtml-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
</style>

<span class="k-widget k-datepicker k-header" style="width: 136px">
    <span class="k-picker-wrap k-state-default">
    <input class="k-input" type="text" name="searchParam" id="searchParam" placeholder="Name ..." />
        <span class="unselectable k-button k-select">
            <img class="unselectable" src="~/Images/search_flashlight_16.png" />
        </span>
    </span>
</span>
like image 556
sumpubu Avatar asked May 13 '13 18:05

sumpubu


People also ask

How do I add a button to a textbox?

What you need to do is put both the input field and the button in one container, you set that container to be positioned relatively and you set the button to be positioned absolutely. It's important that the container is positioned relatively, so to make sure the button stays within the input field.


1 Answers

Everything you should need is this: See jsFiddle DEMO

<span class="k-textbox k-button k-space-right">
    <input value="This is the value" />
    <a class="k-icon k-filter"></a>
</span>

Also see the "documentation" (Look at the source for the example) for this here.

EDIT: Since the asker really wanted it to behave as a button (i.e. the click-effect), just add the k-button class to the outter span.

like image 78
Shion Avatar answered Oct 01 '22 10:10

Shion