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 7817875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:23:18+00:00 2026-06-02T06:23:18+00:00

I’ve been working on a custom form completion for a site/tool I’ve been building.

  • 0

I’ve been working on a custom form completion for a site/tool I’ve been building.

I got the search to work, it displays the results in a little div below the input field. I want to allow a user to see the results, click on the appropriate result, and allow it to populate the form fields with the corresponding data. This works when the data has no special characters in it (IE an apostrophe), but if it has an apostrophe, the function call breaks. I know well enough to have the special characters changed into HTML special characters:

'

And, I have done that when adding the data to the database. The problem is, since the function call is placed via AJAX into a div, the HTML special character is “evaluated” when placed into the page, and becomes the literal character. Here is an example of the function call:

onclick="popForm('1234', 'Some Name', 'Another Name', 'Someguy's Thing', '5678')"

Here’s a list of all that I’m trying to do:

  1. User enters data into a field
  2. A javascript function captures the input via onkeyup(), and processes it
  3. The function uses AJAX to make a call to a PHP script
  4. The PHP script performs the search, grabs the results, and echo’s a table containing the results, as well as a function call for onclick to populate the fields.
  5. Javascript handles the results from AJAX, and adds the results to a div’s innerhtml.
  6. User clicks on a result, onclick is triggered, makes function call with string arguments wrapped in single quotes
  7. Function adds the strings to the appropriate fields via
    document.getElementById(“fieldname”).value=string;
  8. User submits form

Currently, we get all the way up to step 6, which is where it breaks, due to the literal apostrophe in the function call.

Any ideas on how to remedy this?

  • 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-02T06:23:19+00:00Added an answer on June 2, 2026 at 6:23 am

    I would seriously consider re-writing your logic.

    1. don’t use inline DOM0 event handlers – they’re error prone for exactly this sort of reason
    2. Return data, not function calls – eval is bad, mkay?
    3. Bind a proper event handler (ideally using element.addEventListener) to a first-class function created on the fly and attached to the appropriate element
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.