I would like to write "hello world", no in the code but in the page linked to the script

I have this coice on the web page:

How can I substitute "(" hello Wold) ", to write it on the page directly?
Codicce

How does the property Webviewer.WebViewString work?
Taifun

I have exactly those blocks, but I would like to have the ability to view the text that appears in the WebPage and transfer it to the text box

Let me explain better:

  1. I create a web page with a text written on it
  2. with a button, I would like that text to be transferred to the textbox.
    In the example of your blocks, the opposite happens, i.e. from the textbox, the text is sent to the web page.

Something like this:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<head>
	<title>ShowAndReturn</title>
</head>
<body>
	<p id = "pVal">Hello World</p>
	<script>
	var mytext = document.getElementById("pVal").innerHTML;
	window.AppInventor.setWebViewString(myText);	
	</script>
</body>
</html>

I don't know, now I'm going to try it and I'll be able to tell you.
In the meantime, thank you for your always excellent assistance, but solving this problem is very important to me, can you explain to me how it works?
Because I know something html but not enough and I make a huge effort to do tests and counter-tests to understand how I have to act.

Let's see if I can once again make myself understood.
I must have the ability to create a screen1 and a Screen2 with a WebViewer component. in the first and a Textbox for the second Screen.

I will prepare a Web page with a software for Web pages where Inside I will insert a window (text box) to be able to have the user type a text directly into the web page.

Once the compose app is started, WebVIewer will load the prepared web page in turn and the user can enter the text he wants in the text box that I will have entered on the page.
At the push of a button, the text from the web page (from the text box) should be able to be transferred to the Screen2 texbox.

In a nutshell, I don't have to put the text into the Script, like "Hello Wold" in your example, because it would be useless. While, I have to allow the user to do it, directly on the Web page, through a text box that I will have entered.

I certainly can't tell him go to the page crypt and replace "Hello Wold" with the text you want and then send it to the texbox.

OK, now you have explained (for the first time) exactly what you want, try this:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<head>
	<title>ShowAndReturn</title>
</head>
<body>
	<input type="text" id="textbox"><br><br>
	<button id="click" onclick="getText()">Enter Text</button><br><br>
	
	<script>
	function getText() {
		var myText = document.getElementById("textbox").value;
		window.AppInventor.setWebViewString(myText);
		}
	</script>
</body>
</html>

You will need the webviewstring Changed event to capture the new value of the webviewstring, then set this as the start value for Screen 2.

Not sure why you need to do this in a web page, a simple textbox and button on your app could do this...

1 Like
ShowAndReturn
<input type="text" id="textbox1"size="60" maxlength="60"><br><br>
<button id="click" onclick="getText()">Enter Text</button><br><br>

<script>
function getText() {
	var myText = document.getElementById("textbox1").value;
	windowAppInventor.setWebViewString(myText);
	}
</script>

The code for the window is perfect, just what I needed, you were really great, but:

  1. I can not enlarge the text box, to lengthen it yes.
  2. I don't know how to use the button you inserted on the web page, it doesn't give any results.
  3. I changed the code to make it usable for me but it seems that I must have done something wrong even in the blocks,
    check them out please

Also I forgot to write, that the text box where the user has to type a text must be multiline and I must be able to enlarge it. both in length and in height.
I am looking on the net but I only find text boxes that allow you to enter data such as: Name-Surname, therefore in one line and not in multiple lines.

I found this in:

If you need to indicate a field that allows you to enter a large amount of text, it is better to use a "textarea" (text area) instead. Here is the syntax:

here you can write your text Textarea HTML <input type The rows attribute indicates the number of rows in the textarea, cols the number of characters (ie columns) that each row can contain.

As you can see, if you want to indicate predefined text in this case you have to insert it between the opening and closing of the tag.

but I don't know how to use it and where to insert it.

In emulation and compiled it uses http://localhost/my_web.htm

Read the @TIMAI2 post... You will need the webviewstring Changed event...

Thanks to you too, for your suggestion.
I had thought of this solution but it forces me not to update the web page.
I need the web pages to be managed by me and must not be fixed, but always interchangeable with the text box inside, which must allow the user to enter his own text and send it to a texbox, whenever he wants. he.

You can use css / inline styling to size your input box.

See attached aia project

returnwvs.aia (2.4 KB)

Thanks, it works but I don't know how to resize the text area, make it multiline.
I'm not familiar with CSS

Thanks, it works but I don't know how to resize the text area, make it multiline.
I'm not familiar with CSS
Is it not possible to carry out the transfer operation with a button in the app instead of on the web page?

It may be better to use a "textarea" instead of a "text" as input.

Yes, you can send a value using the webviewstring to the page, and add more/different javascript to call/handle the return of the text content to the new webviewstring value.

I know that you believe me capable of doing it, I will try as I have been trying to do for about three days but without results, so I turned to the forum.

I had the code that I posted, but this script, to transfer the text to a label or a texbox, needed the text to be reported in the html code and therefore in the script.

é Certainly it worked and it was simple, but I as written, I needed to write the text outside, directly on the web page and from there to bring it back, as you did in an unalabel or in a textbox, which is already, a great help really and you I am grateful.

I am not able to render the text box multiline, I have searched this on the net, and I have found the code that I have posted in this thread, but not knowing how to insert it in the script nopn I could proceed.
Let's connect an external button to the page, to the code.

Thought you might say something like that :wink:

Try this aia project

returnwvs2.aia (3.2 KB)

html:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<head>
	<title>ShowAndReturn</title>
	<style>
	textarea { font: 12px "Arial"; }
	</style>
</head>
<body>
	<br><br>
	<textarea id="textbox" rows="8" cols="40" style="border:solid 2px black;"></textarea>
	
	<script>
		setInterval(function () {
		var wvs = window.AppInventor.getWebViewString();
		if (wvs == "fetch") {
			getText();
		}
		}, 1000);
			
	function getText() {
		var myText = document.getElementById("textbox").value;
		if (myText != "") {
		document.getElementById("textbox").value = '';
		window.AppInventor.setWebViewString(myText);
	    }
	}
	</script>
</body>
</html>

I tried to insert a textarea, but as you see I don't really know how to connect it to I tried to insert a textarea, but as you see I don't really know how to connect it to the button by replacing the other smaller textbox.

here you can write your text How should I enter it? where should i insert it? what should i delete? How can I connect the button to the new larger box and transfer the text to the label? Unfortunately sorry but I don't know anything about codie html. i have created sites sometimes am i created them using block programs without writing code.

Great, thanks but the button to transfer the text is missing.

You want to transfer text from a label/textbox in the app, to the textbox in the web page ? - the complete opposite of what is happening in my last aia project ?