Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:04:42+00:00 2026-06-17T13:04:42+00:00

HTML <input type=’text’ id=’searchable’value=’hello world’ /> <input type=’hidden’ id=x value=’hel’ /> how can i

  • 0

HTML

<input type='text' id='searchable'value='hello world' />
<input type='hidden' id=x value='hel' />

how can i select textfrom #searchable starting from end of value of hidden input till end of #searchable ?

Fixed thanks all

    $('input.complete').live('keyup.autocomplete', function(){
        var hi=$(this).val().toUpperCase();
        var was=this;//PROBlEM was here... was=$(this)
            $(this).autocomplete({
                source: function(request, response) {
                        $.ajax({ url: '<?=base_url()?>ajax/ac',
                        data: { 'term': this.term,'page': 'clinic','key': this.element.attr('data-complete')},
                        dataType: "json",
                        type: "POST",
                        success: function(data){
                            if(!data.length){
                                var result = [{label: 'No match found',value: response.term}];
                                response(result);
                            }else{
                                response(data);
                                $(was).val(data[0]['value']);
                                was.selectionStart=hi.length;
                                was.selectionEnd=data[0]['value'].length;
                            }
                        }
                    });
                },
                select: function(event, ui){},
                minLength: 2,
            });
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:04:42+00:00Added an answer on June 17, 2026 at 1:04 pm

    Try this out

    (function() {
        var search = $('#searchable')[0],
            searchvalue = search.value,
            xtext = $('#x').val(),
            startAt = searchvalue.indexOf(xtext) + xtext.length;
        search.selectionStart = startAt;
        search.selectionEnd = searchvalue.length;
    }());
    

    Live demo

    If x value always start matching at the first character of search’s value, the searchvalue.indexOf(xtext) is redundant as it will always return 0 and can be safely removed.

    References:

    • Dottoro: selectionStart, selectionEnd
    • MSDN: selectionStart, selectionEnd
    • MDN: HTMLInputElement Properties

    Note: As selectionStart and selectionEnd are part of HTML5, there’s no IE < 9 support. If you’re rolling out your own typeahead, I suggest feature testing these before applying the the autocomplete in the text input element if you plan to support old IE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML: <input type=email id=email> I want to type text into
I have a form with different html input fields... 1) <input type=text> 2) <textarea></textarea>
I want to use the placeholder attribute for HTML input[type=text] elements such that the
How to change the color of content in HTML input type text while entering
In an html page I have input type='text' and a button filename: [ ]
I have the below code in my .aspx page. <input type=hidden id=fbinfo name=fbinfo value=
I have an html select box and a search field (input type) When I
In html code I am using code <input type = text id = abc@def.com>
How to remove input type - value text when user click on it. How
If I have an HTML input field like this one: <input type=text id=mytextfield/> all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.