Populate an ASP Form using Javascript in Android Studio

Being relatively new to Android studio, I have been experimenting with various methods but now need some assistance. I am looking to input data into an ASP.NET Website-form using Android studio. The traditional JavaScript approach does not seem to be effective here.

myWebView.loadUrl("javascript: document.getElementByTagName('Benutzername').value = 'test'");

as well as

myWebView.loadUrl("javascript:document.getElementByName('<%= Benutzername.ClientId %>').value = '"+username+"';");

Is not producing the desired results :/

The HTML code for the input field is as follows:

<input name="Benutzername" type="text" style="text-align: center;  width:120px;border:solid 1px #6699CC;" onkeypress="{if (event.keyCode == 13){document.form1.Passwort.focus()};}" value="">

In the source code, this snippet can be found:

<td width="109" height="30"><div align="right" class="Stil12"><font face="Arial, Helvetica, sans-serif"><font size="3"><font size="2">Passwort:</font></font></font></div></td>
            <td width="126"><input name="Passwort" type="password" style="text-align: center; width:120px;border:solid 1px #6699CC;"
            onKeyPress="{if (event.keyCode == 13){if (Feldpruefung()) submit();};}" value="">
            </td>

I have been unable to make it work and attempting to simulate keypresses has also proved ineffective. Does anyone have any suggestions or ideas?

Answer №1

It seems like the issue may be connected to the settings of your webview. Make sure to add the following code right after initializing your webview.

WebSettings settings = myWebView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient()());
myWebView.setWebChromeClient(new WebChromeClient());

If you need to invoke a method from your Java side using JavaScript, remember to utilize JavascriptInterface. You can refer to this resource for more information.

In regards to the line: document.getElementByTagName, it appears that the function you are attempting to call does not exist. Try using this alternative:

document.getElementsByTagName('some_name')[0].value = 'some_value';

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

Restricting the Zoom Functionality in a Web-Based Project on a Touch-Enabled Display

I am currently working on a project that is web-based and runs on localhost. I need to prevent users from zooming in on the user interface. Is there a way to accomplish this using JavaScript? And can I achieve this restriction specifically on Google Chrome ...

Exploring Grunt (node): Ways to Display Available Tasks

While I am accustomed to using Rakefile, Cakefile, and Jakefile, each of them offered a convenient method for listing the tasks available. For example: jake -T jake db:dump # Dump the database jake db:load # Populate the database ...and so ...

Send any Json Object in the Query Parameters along with a String

Hello everyone, I've written the following code : @POST(/test) void test(@QueryParam("param1") String param1, @QueryParam("param2") String param2) { //some computations (converting param2 into bytes) } I need to pass a JSON object ...

How to insert a new document into a MongoDB collection with Mongoose

Consider a scenario where my existing collection called fruits is structured as follows: {"_id" : ObjectId("xyz...."), "name" : "Apple", "rating" : 7} {"_id" : ObjectId("abc...."), " ...

When you click, transfer a single item from one array to another and modify the text according to the items in the array

How can I dynamically update a shopping cart feature on my website when a user clicks on the "addtocart" button? I want to create functionality where clicking on the button adds the corresponding product to the cart array, and updates the cart amount displ ...

What methods can a Discord Bot use to respond with specific messages to individual users?

Hey there! I'm dipping my toes into the world of coding and thought it would be fun to create a Discord bot that gives different responses each time it's mentioned. Just so you know, I'm working with Discord.js version 13 for this project. ...

Trigger a series of functions upon clicking with ReactJS

Need some assistance with an alert message functionality. I have a button labeled Checkout, and when clicked, it should clear the cart and display an alert. At present, the individual functions work as expected - calling emptyCart() works fine, and calling ...

"Utilizing Criteria API and Query DSL for efficient database querying

When utilizing the canonical meta model in JPA 2, it offers robust type safety. However, the level of type safety with querydsl is uncertain. Which option is more reliable in terms of type safety and why? ...

Watch the video and follow along with your mouse using jQuery

Wouldn't it be cool to have a video play and follow your mouse pointer when you hover over the red box? And then once you move away, the video stops and disappears. Check out my progress so far: jsfiddle Here's the jQuery code I've used: $ ...

C# Update Operation Failing to Work with SQL Rows

I'm struggling to understand why the code below is not updating my GridView or MySQL Database. Can someone provide me with some advice on what mistakes I might be making? protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) ...

Using SignalR across multiple application pools

Currently, I am in the process of sending notifications to specific clients from the server regarding transaction changes. Progress has been smooth in the local and development environments. However, in the LIVE environment, we face a challenge with 3 app ...

Java method to transform a two-dimensional char array into a one-dimensional int array

Currently, I am attempting to create a Java method that will convert an array of characters[][] which are each associated with an integer array[] into an array of integers: public static int charArrayToInt (char[][] Grades, int[] studentList) { int[] ...

There seems to be a compatibility issue between AngularJS and HTML

Here is a simple AngularJS code snippet I have written: var app=angular.module("myApp",[]); app.controller("MyController",['$scope',function($scope){ $scope.name="Asim"; $scope.f1=function(){ console.log("i am clicked"); $scope.vr="lol"; } co ...

Saving integer data retrieved from DynamoDB in a React Native application

I need to store a user's progress by saving a value in a DynamoDB. While storing the value is not difficult, accessing this value for use in my application has proven to be quite challenging. When using dynamoDBWrapper.getItem(params), where the para ...

PostgreSQL dynamic query with Node.js

I am currently developing a note-taking app using REACT. My focus is on tracking only the changes made by the user to the note, rather than the current state of the note. For properties that have not been altered, I intend to send them as an empty string ...

Steps to partially open the Modal Sheet Swipe Step by default

I've set up a modal sheet component with the following structure: <f7-sheet class="myClass" style="height: auto" swipe-to-step :backdrop="false" > <div class="sheet- ...

react-i18next - The function call does not match any overload when the specified type is `string`

I am currently utilizing react-i18next in conjunction with React and TypeScript. Interestingly, when I attempt to load a property using a string literal and type inference, everything works seamlessly. However, once I specify the type as string, an error i ...

What is the best way to convert HTML into a React component?

This is the situation I am facing : 1) The application requests a CMS (Content Management System) for page contents. 2) The CMS responds with "<div>Hi,<SpecialButton color="red">My Button</SpecialButton></div>" 3) The applicat ...

What is the best way to incorporate and execute a separate JavaScript file in a Node application using Express JS?

I am attempting to configure a javascript file that is responsible for grabbing an RSS feed and storing the information in a database. Originally, I had this file called by the HTML page, but now I want it to continuously run in the back-end (constantly re ...

What should I do to resolve the message 'Ignoring invalid configuration option passed to Connection' that I received?

This is the latest message: Warning - Invalid configuration option passed to Connection: createDatabaseTable. Currently a warning, future versions of MySQL2 will throw an error for passing invalid options. The application stops responding after enco ...