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

  • Home
  • SEARCH
  • 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 8064015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:14:16+00:00 2026-06-05T11:14:16+00:00

I have returned a form with some key value pairs populated. Depending on user

  • 0

I have returned a form with some key value pairs populated. Depending on user interaction I want to insert some of them into my HTML. I have found some answers using AJAX but could not workout how to access the key value pairs via javascript. I do not want to use jquery yet as I want understand how javascript and the DOM works first. Below is an idea of what I want to do

<script> 
  function changeanchor(urlitem) {
    document.getElementById("urlanchor").innerHTML = "";  
    while ($urls as $url) {
      if (urlitem == $url->item) {
        document.getElementById("urlanchor").innerHTML .= $url->urlanchor;
      }
    }
</script>

I know “$urls as $url” etc is PHP but I thought it was the easiest way to explain what I need to do.

I use PHP to generate the function call but I am unable to get it to display here it (pieces of code do not display)

  • 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-05T11:14:18+00:00Added an answer on June 5, 2026 at 11:14 am

    Like so?

    <script> 
      function changeanchor(urlitem) {
        document.getElementById("urlanchor").innerHTML = ""; 
    
        for (i in urls) {
          var url = urls[i];
    
          if (urlitem == url.item) {
            document.getElementById("urlanchor").innerHTML += url.urlanchor;
          }
        }
    </script>
    

    urls was never defined so this code won’t execute unless urls stores a bunch of url objects with those properties.

    In order to create a url object that acts like the one you try to use, either use JSON to pipe it to the JavaScript or make an object:

    var urls = [
      {
        'item': 100,
        'urlanchor': 'foo'
      }, {
        'item': 200,
        'urlanchor': 'bar'
      }
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data of the form Key ID Link 1 MASTER 123 2
Within a form I have a user control for each field being returned. The
I have an application that consists of two forms. One form displays data returned
I have a void pointer returned by dlsym(), I want to call the function
I have a string being returned from my database that I want to use
The following is a sketch of how I might have some form of automated
I have a PHP form that needs some very simple validation on submit. I'd
I'd like to encapsulate Win32 errors (those returned from GetLastError()) in some form of
Within an web form I have a some input fields <div id=search1> <div class=forminput>
I have a complex html-Form and am using jQ for some of the work

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.