From HTML textarea to RB textarea

new BookmarkLockedFalling
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jun 30, 2008 2:03:39 GMT -5

I want to type something in the small textarea, click on "Save JS Value", and transfer the contents of the small HTML textarea to the large RB textarea. Is the "wait" killing the transfer?

cls
html "<textarea id='txx'></textarea>"
print ""
html "<a href=""#"" onclick=""document.getElementById('nodisplay').value = document.getElementByID('txx').value;"">Save JS Value</a>"
print
cssid #nodisplay,"{display:inherited;}"
textarea #xyz, ""
#xyz SetID("nodisplay")
print ""
link #abc, "Is it really saved?", [yup]
wait

[yup]
print
string$=#xyz contents$()
print "JS value = ";string$
Last Edit: Jun 30, 2008 2:09:09 GMT -5 by Jerry Muelver
kokenge
Senior Member
****

kokenge Avatar

Posts: 261

Post by kokenge on Jun 30, 2008 7:18:44 GMT -5

Hmmm! Not sure why your code don't work. So no help there.
However I have a similar routine that works.
Maybe it will be of some help..


TITLEBAR "Move Over"
html " <script type='text/javascript'>
<!--
function ClickHandler ( )
{
document.getElementById('b').value =
document.getElementById('b').value + ' ' +
document.getElementById('a').value;
document.getElementById('a').value = '';
}
//--></script>
"
html "<table><TR><TD>"
textarea #a,"",10,4
#a setid("a")
html "</td><td>"
html "<input type='button' name='btn' id='btn' value='>' onclick='ClickHandler()'/>"
html "</td><td>"
textarea #b,"",20,8
#b setid("b")
html "</td></tr></table>"
end


HTH
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jun 30, 2008 7:37:17 GMT -5

Thanks! I'll play with that a bit. However, I really need for the transfer to go from an HTML textarea (created by a JavaScript routine) to an RB element or var, so I can use RB to load and save file contents to the HTML textarea. I'm hoping some kind of tweak in my posted code will do the trick. If not, I'll wind up with a glorious write-only, no-save, no-load WYSIWYG editor, which would seriously limit its acceptance in the computing world. ::)
carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jul 1, 2008 6:30:28 GMT -5

Could be making progress, here....

Kokenge, this works (create textarea in HTML):

TITLEBAR "Move Over"
html " <script type='text/javascript'>
<!--
function ClickHandler ( )
{
document.getElementById('b').value =
document.getElementById('b').value + ' ' +
document.getElementById('a').value;
document.getElementById('a').value = '';
}
//--></script>
"
html "<table><TR><TD><textarea id='a'></textarea></td><td>"
html "<input type='button' name='btn' id='btn' value='>' onclick='ClickHandler()'/>"
html "</td><td>"
textarea #b,"",20,8
#b setid("b")
html "</td></tr></table>"
end

So, maybe I need to fancy-up my handler a bit. ::)
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jul 1, 2008 6:59:39 GMT -5

Closer:

TITLEBAR "Move Over"
html "
<script type='text/javascript'>
<!--
function ClickHandler ( )
{
document.getElementById('b').value =
document.getElementById('a').value;
}
//--></script>
"
html "<textarea id='a'></textarea><br>
<input type='button' name='btn' id='btn' value='Xfer' onclick='ClickHandler()'/>"
print
textarea #b,"",20,3
#b setid("b")
print
link #xyz, "Show it", [showit]
wait

[showit]
string$ = #b contents$()
print
print string$

Type in top box, click "Xfer", and it goes. Add to top box, click "Xfer", and bottom box gets rewritten with new contents. Click "Show it", and contents of bottom box gets printed. However, top box gets cleared. Why? Also click "Show it" a second time, and program crashes. Need a loop?
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

Last Edit: Jul 1, 2008 9:42:56 GMT -5 by carlgundel
kokenge
Senior Member
****

kokenge Avatar

Posts: 261

carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

kokenge
Senior Member
****

kokenge Avatar

Posts: 261

Post by kokenge on Jul 1, 2008 16:33:03 GMT -5

Like usual, I guess I'm missing something.
Here is a test I did with 4 textareas. 2 RB areas and 2 outside RB.
a - RB
aa - Outside RB
b - RB
bb - Outside RB

Put something in a and aa, click [>] and it moves it to b and bb. And sends a message back to a and aa just to make sure I'm seeing it.

When you click the [show Me] link , it makes the round trip and shows you what is in b. I realize I cannot see bb in RB because he don't know about it. Noticed I commented those out in the [showMe] area.

TITLEBAR "Move Over"
html " <script type='text/javascript'>
<!--
function ClickHandler ( )
{
document.getElementById('b').value =
document.getElementById('b').value + 'a=' +
document.getElementById('a').value + '|aa=' +
document.getElementById('aa').value;

document.getElementById('bb').value =
document.getElementById('bb').value + 'a=' +
document.getElementById('a').value + '|aa=' +
document.getElementById('aa').value;

document.getElementById('a').value = 'clear a';
document.getElementById('aa').value = 'clear aa';
}
//--></script>
"
html "<table><TR><TD>RB area (a)<BR>"
textarea #a,"",10,4
#a setid("a")
html "</TD><TD>Outside RB area (aa)<BR>"
html "<TEXTAREA id='aa' ROWS=4 COLS=10></TEXTAREA>"
html "</td><td>"
html "<input type='button' name='btn' id='btn' value='>' onclick='ClickHandler()'/>"
html "</td><td>RB area (b)<BR>"
textarea #b,"",20,8
#b setid("b")
html "</td><td>"
html "</TD><TD>Outside RB area (bb)<BR>"
html "<TEXTAREA id='bb' ROWS=8 COLS=20></TEXTAREA>"

html "</td></tr></table>"
link #shoMe,"Show Me",[shoMe]
wait
[shoMe]
b$ = #b contents$()
'bb$ = #bb contents$()
print
print "RB box (b):";b$
'print "Outside RB box (bb):";b$
wait
end





Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jul 1, 2008 20:19:28 GMT -5

Clicking on the link causes a round trip. Data goes into the server, and the page is recreated. When this happens the textarea won't have anything in it because RB doesn't know the textarea exists, and it won't stick anything into it.

That's interesting, and certainly explains what I've been seeing. I'll have to absorb this paradigm, and figure out an adaptation.
Run BASIC does not maintain the contents of widgets that it didn't create. It doesn't even know they are there.

Why not replace

html "<textarea id='a'></textarea>"

with

textarea #a,"",20,3
#a setid("a")

I'm working on that line of thinking. However, John Gordon's WhizzyWyg JS script grabs the declared textarea by its ID and reconfigures it as a rich-text editing box. It'll simplify things for me if I can still retrieve the contents of the control as an RB widget, of course. Might not work, but I'll find out. I have to figure out how to deal with recreating the page and its contents after the "Save" loopback from the server, maybe just read the newly-saved file back in to repopulate the newly recreated rich-text box. Where there's a will, there's a way.... ::)
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Jul 1, 2008 20:22:26 GMT -5

kokenge Avatar
Like usual, I guess I'm missing something.
Here is a test I did with 4 textareas. 2 RB areas and 2 outside RB.
a - RB
aa - Outside RB
b - RB
bb - Outside RB
....

Thanks. I appreciate your "tests" and find them very helpful to work with and experiment. I think I'm getting a handle on this RB <-> JS transfer stuff now.