Internet Explorer and JavaScript are two important components of web

I'm encountering an issue with my registration page where it functions properly in Firefox, but IE 6-8 displays a 'document.info.altDate1.value' error upon submission.

Here is the structure of the body:

<DIV id=wrapper>
<DIV id=outer-space>
<DIV id=hfeed>
<H1>Register for <SPAN>Orientation</SPAN></H1>

...

The problem seems to be linked to these specific fields:

<SELECT id=freshmandate name="">

and

<SELECT id=transferdate name="">

as well as this function:

 if (document.info.StudentType.value == 'F')
  {
  document.info.freshmandate.name = 'altDate1';
  document.info.amount.value = '105.00';
  }

 if (document.info.StudentType.value == 'T')
  {
  document.info.transferdate.name = 'altDate1';
  document.info.amount.value = '75.00';
  }

A friend suggested using GetElementByID for better compatibility in IE, but I'm unsure how to implement it effectively for my requirements.

Edit 1: I attempted the following approach which didn't work and now even Firefox has issues:

if (document.info.StudentType.value == 'F')
{
document.getElementById('freshmandate').name = 'altDate1';
else
document.getElementById('transferdate').name = 'altDate1';
}

Answer №1

When assigning an ID to the select element, make sure to reference it using the correct attribute, such as the name attribute.

<SELECT id=freshmandate name="">

document.info.freshmandate.name = 'altDate1';

If you encounter issues, it is recommended to set the name attribute of your select element or use document.getElementById instead:

document.getElementById('freshmandate').name = 'altDate1';

Consider the purpose of setting the name property for #freshmandate. What are you trying to achieve with this action?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Polymer: Basic data binding is not functional in the second element

After dedicating 6 hours to this problem, I still can't seem to find a solution. Below is the code snippet from index.html: <flat-data-array availableModes="{{modes}}" id="dataArray"></flat-data-array> <flat-strip-view availableModes=" ...

`Is it challenging to convert JSON into HTML, leading to undefined results?`

I am currently attempting to extract YAHOO data by utilizing getJSON and YQL. Although the connection is successful, I can retrieve the data and log it in the console. However, I am facing difficulties when trying to display this data on the JSP page I am ...

Passing a JavaScript variable when using res.render in Express

Currently, I am working on a project where I aim to develop a small app that can call data from a config.js file in JSON format and display it on a page based on the value of the name key within the JSON. app.get('/:verb', function(req, res) { ...

sending arguments directly to a utility function

Here is a common function I have for sorting: export const sortSelectOptions = (options, sortByKey = 'name', type) => { switch (type) { case 'alphaNumeric': return options .slice() .sort((a, b) => ...

Break down an array-like object with no duplicates

I'm currently learning about working with JavaScript arrays and have a question regarding creating new array objects by splitting an attribute of an existing object. I attempted using methods like .map and .flatMap, but the output I received consiste ...

Understanding the moment when the DOM is fully rendered within a controller

I'm currently facing an issue with AngularJS. In my controller, I have a $watch setup like this: function MyController() { $watch('myModel', function() { $rootScope.$emit('do-oper'); }); } The value of 'myMod ...

AgGrid Encounters Difficulty in Recovering Original Grid Information

After making an initial API call, I populate the grid with data. One of the fields that is editable is the Price cell. If I edit a Price cell and then click the Restore button, the original dataset is restored. However, if I edit a Price cell again, the ...

The initial dropdown menu in PHP coupled with Javascript fails to retain my chosen option

As a novice PHP programmer, I successfully created a double drop-down list from a MySQL database. The idea is to choose a claims hub in the first box and then select an attorney associated with that specific hub in the second box. However, I am facing an ...

What is the process for displaying a three.js project?

I've been trying to follow a beginner's tutorial on three.js from this link, but I'm encountering an issue in part 2 where nothing seems to render on my webpage. Despite checking out other guides, I can't seem to solve the problem. I u ...

jQuery fails to make a POST request when the content type is set to application/json

I am utilizing jQuery version 1.10.1. My goal is to execute a POST request with the content type set to application/json. The code I have implemented is as follows: $.ajax({ type: "post", url: urlBase + "user/search", contentTy ...

Variable value reversal during callback execution

Is there a way to accomplish this? To start, take a look at the following code... function flutter() { var random = Math.floor(Math.random()*5); var $obj = $('.bird'); $obj.animate({ top :'-=' + random + 'px' }, ...

Is there a way to unveil an additional field in a Django form only when a checkbox is selected?

Can this be achieved using Django exclusively, without the need for Javascript? ...

Node.js is executing the CRON process twice

Within my Node.js application, I have set up a CRON job that runs every day at 10 AM to send push notifications to users. However, I am encountering an issue where two notifications are being sent to the user's device each time the CRON job is trigger ...

Adding the data from an ajax object response to an array

I'm encountering an issue where my Ajax response is not being properly looped through each object and pushed into the array. I've been stuck on this problem for quite some time now. The Ajax response looks like this... {type:'blog_post&apo ...

Developing NodeJS applications locally using Docker

How can I effectively develop an app locally within a container with access to my laptop's file system for the node_modules? Currently, my Dockerfile includes the following settings: COPY package.json /app/ RUN npm install COPY . /app/ And my docke ...

Steps to trigger a modal (bootstrap 5) in react upon clicking a cell within the Full Calendar interface

My goal is to trigger a modal window using Bootstrap 5 (not React-Bootstrap library) when clicking on a day in the FullCalendar Component in React. I attempted to access the modal by using jQuery's $, but encountered the error message "$ is not a fun ...

Linking Two HTML Components in Angular 4 with Identical Values

Recently, I've started working with Angular and encountered an issue. In a table row, the value item.md_id is bound like this: <tr *ngFor="let item of driverData"> <td class="align-right" id="md_id" [(ngModel)]="item.md_id" name="driverId ...

What is the best way to split a text box into sections, making sure that each section can only contain a single

My task is to develop a registration form One of the requirements is to design a textbox that can be divided into multiple sections, each allowing only one character input as shown in the image. I am unsure how to accomplish this division while still bei ...

Changing a JSON array into an HTML table using jQuery

Can anyone suggest a simple method to convert an array of JSON objects into an HTML table while excluding specific fields? Or do I have to handle this task manually? ...

Transforming a JavaScript component based on classes into a TypeScript component by employing dynamic prop destructuring

My current setup involves a class based component that looks like this class ArInput extends React.Component { render() { const { shadowless, success, error } = this.props; const inputStyles = [ styles.input, !shadowless && s ...