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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:02:16+00:00 2026-06-18T08:02:16+00:00

I’m trying to redirect to my ServletController via an anchor tag and javascript. Now

  • 0

I’m trying to redirect to my ServletController via an anchor tag and javascript.

Now it works in Google chrome and not in IE. I looked around the web for two days so far and found that IE does not work with setAttribute well with dynamic elements so I had to switch to using the actually attribute and assigning it a value.

The anchor is suppose to create a dynamic form and make a form submission which then creates a new request to my Servlet but for some reason when I click on the anchor in javascript it does nothing. However when I click on the anchor in chrome it does it correctly and redirects me to the next page without any problem.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Account</title>
<meta name="description" content="eTeam Bank">
<meta name="author" content="Abraham Cabrera">
<link rel="stylesheet" type="text/css" href="css/mystyles.css">

<!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
<script type="text/javascript"> 
function anchorRedirect(username, user_id, operation) {
"use strict";
var form = document.createElement("form");
form.name="form";
form.id="form";
form.method = "post";
form.action = "ServletController";

var hiddenField1 = document.createElement("input");
hiddenField1.type = "hidden";
hiddenField1.name = "username";
hiddenField1.value = username;
form.appendChild(hiddenField1);

var hiddenField2 = document.createElement("input");
hiddenField2.type = "hidden";
hiddenField2.name = "user_id";
hiddenField2.value = user_id;
form.appendChild(hiddenField2);

var hiddenField3 = document.createElement("input");
hiddenField3.type = "hidden";
hiddenField3.name = "operation";
hiddenField3.value = operation;
form.appendChild(hiddenField3);

form.submit();
}
</script>
</head>
<body>
<header>
    <div id="title">eTeam Bank</div>
</header>

<div id="container">
    <div class="userTitle" >
        <div class="user">
            Welcome: user
        </div>
        <div class="userTime">
        Thu Jan 31 09:24:16 EST 2013
        </div>
    </div>
    <div class="accountBox" >
        <div class="accountSpace"></div>
        <div id="accountAnchor">
        <a href="javascript:anchorRedirect('user', '2', 'loadPersonalInfo');">Personal Info</a> 
        </div>
        <div id="accountAnchor"> 
        <a href="javascript: anchorRedirect('user', '2', 'loadAccountInfo')">Account Info</a> 
        </div>
        <div id="accountAnchor"> 
        <a href="javascript: anchorRedirect('user', '2', 'loadAccountSum')">Account Summary</a> 

        </div>
    </div>
</div>

<footer>
    <div id="footerContent">Abraham Cabrera &copy; 2013</div>
</footer>

Additional Details:
1. This is not for any type of production business or corporation and is just for personal studies.
2. I did try passing the variables via the url path directly without using the java script function but that does not meet my requirments because I need to make a new request to my ServletController in order to get the users account information via the model class or which ever operation it was and forward it back to the view.

  • 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-18T08:02:17+00:00Added an answer on June 18, 2026 at 8:02 am

    I suggest to create the form inside the HTML (not via javascript) with all the needed fields inside already. Then, instead of creating and setting the elements, you would radically simplify your JS by simply setting the values of the hidden fields and submitting the form. Something like

    <form name="myform" id="myform" method="post" action="ServletController">
        <input type="hidden" name="username" value="">
        <input type="hidden" name="user_id" value="">
        <input type="hidden" name="operation" value="">
    </form>
    

    with a javascript like

    function anchorRedirect(username, user_id, operation) {
        document.myform.username.value = username;
        document.myform.user_id.value = user_id;
        document.myform.operation.value = operation;
        document.myform.submit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported

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.