Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

How to make tag input in jQuery?

 
Ranch Hand
Posts: 159
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a servlet that read data of jsp, the jsp has a script to append and to remove elements. The function to add or remove elements is in JQuery. JSP have $ character to send data to the Servlet and the JQuery have the same character ($) used to create function and other things. My question is how I mount the input tag to append.

The result of this is that the browser show +codprdCel+ in my input box.
Thanks.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please explain it more better way?
 
Saloon Keeper
Posts: 21964
149
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, "$" does not "send data to the servlet. The "$" on a JSP in this instance is part of the Expression Language (EL), which is a feature of JEE for View Templates - JSPs and JavaServer Faces xhtml file and probably other cases that I can't think of.

The "${}" expression notation says that the EL processor is to evaluate the expression and substitute the results when generating the output. There's also an "#{}" form used by JSF, where the "#" means that the expression can be a read/write property reference, but JSP doesn't have that. "$" is read-only.

When, as is often the case, you have a conflict between EL and jQuery's "$" shorthand, you have to use the long form jQuery syntax, which is "jQuery."

I can't tell if you're trying to use jQuery or EL in your example, but the EL substitution is done when the JSP is sent from server to client, so you cannot use it for dynamic expressions on the client web page. For that, you would need jQuery, but your sample is in EL form and nothing I can recognize as anything like a jQuery function call, so you'll have to explain further.
 
Cezar Apulchro
Ranch Hand
Posts: 159
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a bit little of my jsp:

Line 2 class="itensproduto" is where I append my inputs.
Line 74 and 77 is the content table cell clicked.

When table cell is clicked the append is generated and the browser show the input value and not the content cell.
 
Tim Holloway
Saloon Keeper
Posts: 21964
149
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On thing that will help a lot is if you move all the JavaScript to its own ('.js') file and use a link reference from the HTML page to bring it in. The JavaScript file won't be processed by the EL processor and you won't have to deal with the "$" problem.

Failing that, as I said, use the long form so as to avoid conflicts. So instead of
write


Also, you might want to try using the show/hide element methods instead of actually modifying the DOM. It's generally cleaner.
 
Cezar Apulchro
Ranch Hand
Posts: 159
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my problem of append input tag and to identify the button clicked. My problem now is that when button is clicked to see the ID  only of the input selectde all fields of my  page disappear. Below is my script:

 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic