This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages 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: 65227
95
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
Ranch Hand
Posts: 15304
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
Ranch Hand
Posts: 15304
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
Ranch Hand
Posts: 15304
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