Switch Hidden Input Value When UserControl is in Focus

This task seems deceptively simple, but I'm encountering difficulties trying to make it happen.

Within ResidentAddress.aspx, there are two user controls (AppName.ascx and NavButtons.ascx). My goal is to update a hidden input field on NavButtons.ascx with the value of "TRUE" when a textbox in AppName.ascx has focus. In the codebehind page for NavButtons, I need to be able to access this hidden input field's value.

Here's what I've got so far:

NavButtons.ascx

<input type="hidden" id="IpChangeFlag" name="ChangeFlag" runat="server" value="FALSE" />

AppName.ascx

<asp:TextBox ID="txtFirstName" runat="server"  onFocus="document.getElementsByName('ChangeFlag').value='TRUE';">

NavButtons.ascx.vb

If IpChangeMade.Value.Trim.ToUpper = "TRUE" Then
    MyValue = true
End If

Unfortunately, I am unable to successfully update the value of ipChangeFlad; it always remains as FALSE.

Answer №1

To retrieve the value of the first element from an array returned by getElementsByName, use the following syntax:

document.getElementsByName('ChangeFlag')[0].value='TRUE
'

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

Enhance Your Website with GatsbyJS Custom Scrollbars

I'm struggling to customize the default scrollbar on my Gatsby website with an overlay scrollbar. I want to avoid the page 'shifting' slightly to the left when switching between pages that have scrollbars and those that do not. My attempt i ...

Showing VUE Content Delivery Network

Unable to render v-for with CDN in Vue.js const Gallery = { template: '{{$t('gallery')}} <img :class="[[item.class]]" v-for="(item, index) in carousel" :src="[[item.img]]" alt="img" />' } c ...

Update all other input fields whenever a single field is modified. Implement using AngularJS (Link to Plunker included)

Check out this plunker example at http://plnkr.co/edit/Ll09uMtJEC0HqyGBRPj?p=preview Within the plunker, there are input fields for date, user, and car. It is possible to select values for all three fields. If I attempt to change the date, I would like ...

Following the submission of the ajax form, the page is reloading unexpectedly

I need the voting form on index.php to submit without refreshing the page and display results from an external page within index.php. HTML <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script&g ...

Characteristics of touchend event

How can I capture all touchend events from mobile devices using the following code: $(document.body).bind('touchend', function (e) { var touch = e.touches[0]; // not working ... I am trying to retrieve the touch.screenX, touch.screenY, touch.cl ...

Looping through unknown column names in a DataTable in C# to verify the data present

I am working with a DataTable that is filled with data from an Excel sheet, and now I need to manipulate the data based on what's in each column. For instance, if ColumnA contains a combination of numbers 1, 2, and 3, then I want to keep that column ...

What is the most effective way to assess if two JavaScript arrays contain the same values?

I am looking to specifically identify if the second array contains any values matching a value from the first array, rather than comparing the arrays as a whole. The goal is to return the value that matches in both arrays. To clarify, comparing two arrays ...

Hiding content in HTML with the Display:none property

After exploring various posts on this topic, I am still unable to find a solution that fits my specific scenario. Despite the challenges, I thought it would be worth asking for recommendations. Currently, I have a PowerShell script generating a report in ...

Detecting the State of the Keyboard in Ionic 2

Seeking an easy way to determine if the mobile device keyboard has been opened or closed using Ionic2 and Angular2. Is there a 'keyboard-open' or 'keyboard-close' class that Ionic sends to the body/html? ...

Efficiently select multiple classes in Material UI with just one target

I'm currently working with Material UI and I want to update the color of my icon class when the active class is triggered by react-router-dom's NavLink Here is my code: import React from "react"; import { makeStyles } from "@mater ...

Exploring the iteration of JSON objects within an array using AngularJS

My auto search module has the following JSON structure. I need to iterate through an array of JSON objects and use keys and values as required. I have attempted the code below. However, with the provided JSON object, I am able to retrieve the key but not ...

Unable to locate element in Internet Explorer when using frame switching within Selenium

I am currently working on a project in Selenium that is specifically designed to run in Internet Explorer, but I am encountering issues locating the xpath element. Despite this setback, I managed to make progress in the test by using the switch frame func ...

Encountering the "ERPROTO" error message while attempting to send an Axios request from my REST API

I have set up my API at "localhost:3000/api/shopitems" and it successfully returns the JSON data below when accessed through a browser: [ { "item_available_sizes": { "s": 1 }, "imgs": { "album": [], ...

I often find myself frustrated while using Next.js because the console automatically clears itself, making it difficult for me

I am facing an issue with my form in the Next.js app. Here is how it is defined: <form onSubmit = { async() => await getCertificate(id) .then(resp => resp.json()) .then(data => console.log(data)) }> Whenever there is an erro ...

What is the most efficient method for iterating through an array stored in JSON format?

Looking for help with parsing a JSON file that contains a list of departures. I want to loop through each bus line and display them in separate div elements like this: <div class="bus"> <div class="line">departure.line</div> < ...

Tips for locating a key within an object that houses a specific value in its array

In my Coffeescript code, I have created the following Javascript object: urlSets = a: [ 'url-a.com' 'url-b.com' 'url-c.com' ] b: [ 'url-d.com' 'url-e.com' 'url-f.com&a ...

Calendar control failing to trigger the OnTextChanged event in the textbox

I have integrated a calendar control from the internet for phone use, where users can scroll up and down to select a date and time before clicking 'Confirm' or 'Cancel'. However, I am not familiar with JavaScript. The relevant JavaScrip ...

Track when a user clicks within a specific container in VueJS, excluding clicks on a specific child element

On my page, I have multiple choice question options that are structured like this: https://i.sstatic.net/oMH7t.png The following is the HTML code for the options section so far: <div v-for="(option, index) in optionsForFrontend"> <di ...

Tips on how to indicate a checkbox as selected within an Angular controller

I'm in the process of creating a form for entering new service requests, as well as displaying and editing existing ones. One part of this form includes a list of labeled check-boxes that represent different countries. When an existing request is disp ...

The table vanishes once the AJAX operation has been completed

After clicking the button to request data from my controller, my table disappears inexplicably. The table structure is as follows: <div id="SelectedTm" style= float:right> <table id = "PlyrsTm2" style = float:right> <tr>& ...