Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript Autocomplete

 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two INPUT type="text" boxes.

First is Date and second is description.

For date I am using Jquery UI widget 'datepicker' and for description I am using jquery Autocomplete and defined some names

What I want is...If 12/25/YYYY is selected. I want to autocomplete the second text box with Cristmas and vice versa.

How can I do this with javascript?
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have dates and description. If the date is entered, then the description should autocomplete. Like if 12/25/yyyy is selected, then Christmas should automatically be shown?

I tried this, but its not working. Any help?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code would be much easier to read, and therefore more likely to generate responses, if it were properly indented.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 16 and see if you see anything missing.
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this, its working with only one value. If I have 'else if' or 'if' for multiple values, its not working.

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 17 and tell me what's wrong, and this time, don't ignore my post.
 
Praison Selvaraj
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 17 is

[Removed possible solution. He needs to learn how to debug his code. - GDB]

Thanks,
Praison
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praison Selvaraj wrote:Line 17 is

[Removed possible solution. He needs to learn how to debug his code. - GDB]

Thanks,
Praison


 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good job! Does it work now?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why in the world are you doing this $(this).val().substring(0, 5) over and over again? You only need to do it once. Doing it over and over again will make you app slow.

Eric
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better script to complete description if the date is entered and date if the description is entered.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have so much repeated code in there that is such a waste.

Eric
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic