This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Error in JavaScript Searchbar Code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I've been working on coding a html website with a java-based searchbar, and I recently encountered an error with my main.java page. My java file is used for the searchbar which is activated on the html site through the code:
<input onclick="myFunction()" class="form-box" id="searchbar" onkeyup="search_all()" type="text" name="search" placeholder="Search all...">

This should be working right, but the searchbar still doesn't work although it was working before, so I think the problem is in the java code and that's something I'm not too familiar with. Could someone look over my code and let me know what might be the issue?



Any suggestions would be very much appreciated. Thank you!
 
Saloon Keeper
Posts: 6079
154
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

If you suspect the problem to be in the Java code, post the Java code.

Also let us know how that code (presumably backend code) is triggered - the JavaScript you posted does not access any backend.
 
Rancher
Posts: 4453
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to point out, Java != Javascript.

Considering where (and what) you posted I assume you meant Javascript.

So, what is "not working".
What are you doing when it isn't working?
What happens that shouldn't, or doesn't happen that should?
 
Lotte Blue
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I realize I said Java when I had meant JavaScript - my apologies for the blunder since I'm still relatively new to this. The way the code is supposed to work is that it links to the rest of my html site and activates a searchbar that responds and narrows down the results when one types. The dropdown list shows, but it doesn't respond when one tries to narrow the search. Thank you for your responses!
 
Dave Tolls
Rancher
Posts: 4453
47
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK.
Have you tried to debug it?
Just to see whether it is getting into those methods at all?

F12 will bring up the developer tools on most browsers, and you can use the source tab to get at the code and place breakpoints.

Or simply add lines to your code to print out information to the console, if using the debugger feels a bit daunting.
 
Lotte Blue
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been using Visual Studio Code for my coding and when I tried the debug option it just resulted in an error as follows: Syntax error on token(s), misplaced construct(s)Java
—I'm not sure what this means. Is there anything else I could try? Also, I'm not sure how to get it to print out information to the console.
 
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are getting syntax errors in the IDE, the code sure as heck isn't going to run in the browser. Fix the syntax errors before even trying to run the code.

P.S. The browsers debugger will also lag the syntax errors but if the IDE is giving you the info you need, fix it before even loading it into the browser.

P.P.S. Make sure your IDE is parsing the code as JavaScript ad not Java. The two language have nothing in common except for the unfortunate naming.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!