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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:15:23+00:00 2026-06-18T03:15:23+00:00

In my JSP,I have a Java array menuNames ,I want to assign a value

  • 0

In my JSP,I have a Java array menuNames ,I want to assign a value from that array to a text area.Here below i mentioned the Javascript code,Please advice me to correct the code..

function setMainMenuURL(index) {

document.getElementById("SelectedURL").value=<%menuNames[index]%>;
}
  • 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-18T03:15:24+00:00Added an answer on June 18, 2026 at 3:15 am

    You’re confusing your Java code (in the JSP) and your JavaScript code. The Java code runs on the server-side, before anything is returned to the browser, and has nothing to do with the JavaScript code. The JavaScript runs on the client-side, in the user’s browser, after the Java code has already run.

    What you’re trying to do – which won’t work – is use a JavaScript parameter inside your Java code. Since the Java has already executed, that makes absolutely no sense.

    Your best bet would be to print out the Java array as a valid JavaScript array (saving it to a JavaScript variable), then use that in your JavaScript code. Something like this:

    var javascriptArrayMenuNames = <%= Java code to output JSON representation of the array %>;
    function setMainMenuUrl(index) {
        document.getElementById('SelectedURL').value = javascriptArrayMenuNames[index];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jsp/html form that collects an array of choices from user. For
I have a java servlet that passes an array to a jsp page, on
I have a JSP java application that has a name AAA-master so currently my
I have a jsp that contains a table with some information from db. I
I have a problem here in JSTL, I have an array object coming from
We currently have a java/jsp online web service that includes it's own custom calendar.
I have a Java/Spring MVC/JSP/JSTL webapp. We have a designer that gave us some
I have a Java EE project that contains three files delete.jsp , index.jsp and
I have the following jsp file <%@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1%> <%@ page
On a JSTL/JSP page, I have a java.util.Date object from my application. I need

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.