# Can you help me convert Java code to Thunkable Blocks?

**URL:** <https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597>\
**Category:** Questions about Thunkable X\
**Tags:** solved, beginner\
**Created:** [March 31, 2022, 2:32pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597 "2022-03-31T14:32:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vickycode87xrf6](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vickycode87xrf6/32/116274_2.png) [@vickycode87xrf6](https://community.thunkable.com/u/vickycode87xrf6)\
**Post date:** [March 31, 2022, 2:32pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/1 "2022-03-31T14:32:53Z")

</div>

```auto
@Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                if (type.equals("Register") && url.contains("/Mobile/Register/Register")) {
                    String referralCode = ShareReference.REFERRAL_CODE;
                    if (referralCode.equals("")) {
                        referralCode = "";
```

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [March 31, 2022, 2:38pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/2 "2022-03-31T14:38:24Z")

</div>

Hi @vickycode87xrf6 👋

Thanks for reaching out. If you can post a text description of what this code is supposed to do, I’m imagining you’ll get a much quicker and more meaningful response. We are here to help but the majority of us don’t know Java.

---

<div class="post-metadata">

**Author:** ![vickycode87xrf6](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vickycode87xrf6/32/116274_2.png) [@vickycode87xrf6](https://community.thunkable.com/u/vickycode87xrf6)\
**Post date:** [April 4, 2022, 11:10am UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/3 "2022-04-04T11:10:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/6/c69d1ad6b3478713dd401f51231fd7a8dc5b8d2d.png)  
I need to fix the text in this ID

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 4, 2022, 12:32pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/4 "2022-04-04T12:32:20Z")

</div>

Your code is using an invitation link and extract the referral code from the link to give credit to the one who invited you. This code and the example you show is not part of Thunkable and therefore you will not find good explanation.

---

<div class="post-metadata">

**Author:** ![vickycode87xrf6](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vickycode87xrf6/32/116274_2.png) [@vickycode87xrf6](https://community.thunkable.com/u/vickycode87xrf6)\
**Post date:** [April 5, 2022, 6:03am UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/5 "2022-04-05T06:03:53Z")

</div>

var AgentID = document.querySelector(‘AgentID’);  
AgentID.value = ‘Text’;  
AgentID.readOnly = true;

Please help, how can I use such a command on thunkable?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 5, 2022, 8:05am UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/6 "2022-04-05T08:05:13Z")

</div>

> [@vickycode87xrf6](#):
>
> how can I use such a command on thunkable?

You can only use these commands through a `Web Viewer Extension`

See this example  
[https://x.thunkable.com/projectPage/6093e98c10d4c4028ada2448](https://x.thunkable.com/projectPage/6093e98c10d4c4028ada2448)  
This is the official Thunkable sample app.

---

<div class="post-metadata">

**Author:** ![vickycode87xrf6](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vickycode87xrf6/32/116274_2.png) [@vickycode87xrf6](https://community.thunkable.com/u/vickycode87xrf6)\
**Post date:** [April 5, 2022, 8:58am UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/7 "2022-04-05T08:58:26Z")

</div>

I can’t find import extension

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [April 5, 2022, 10:46am UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/8 "2022-04-05T10:46:30Z")

</div>

It’s not an .aix file @vickycode87xrf6 it’s actually part of the web viewer component itself.

Here’s more:

> **[GitHub - thunkable/webviewer-extension: Communicate between the Thunkable Web...](https://github.com/thunkable/webviewer-extension)**
>
> Communicate between the Thunkable Web Viewer and a website - GitHub - thunkable/webviewer-extension: Communicate between the Thunkable Web Viewer and a website

---

<div class="post-metadata">

**Author:** ![sketch](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sketch/32/109058_2.png) [@sketch](https://community.thunkable.com/u/sketch)\
**Post date:** [April 5, 2022, 12:00pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/9 "2022-04-05T12:00:29Z")

</div>

Looking at your code i am guesing that you are working with a text input component

> [@vickycode87xrf6](#):
>
> document.querySelector(‘AgentID’);

This Will return the first HTML element on the page with the given id/class  
You already have that block in Thunkable it’s the green block refering to your element/component.

> [@vickycode87xrf6](#):
>
> AgentID.value = ‘Text’;

This Will set the text of An text input so you can Use a “set text to” block.

> [@vickycode87xrf6](#):
>
> AgentID.readOnly = true;

This is not supported by Thunkable.  
You can Use a label if you want your text input to be Read only.  
Alternativly you can do as @muneer and @domhnallohanlon suggested.

Hope that helps

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [July 4, 2022, 12:01pm UTC](https://community.thunkable.com/t/can-you-help-me-convert-java-code-to-thunkable-blocks/1811597/10 "2022-07-04T12:01:24Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
