|
Post by colinmac on Feb 21, 2012 13:57:52 GMT -5
hello All,
is it possible to make text in a text box static, like STATICTEXT in liberty basic? I would like the textbox after 'this is your favourite colour ' not to be editable.
I would also like to eliminate the 'confirm' button in the example below, but that is another story (involing javascript I suspect, which I wish to avoid for now).
Thanks, Colin
' textbox thing global #writeout dim colours$(2) colours$(0) = "red" colours$(1) = "green" colours$(2) = "blue" listbox #colourbox, colours$(),1 button #writeout , "confirm colour " , [writeout] html " <br> " print " this is your favourite colour: " ; textbox #colourtext , " " , 20 wait
[writeout] selectedColour$= #colourbox selection$() #colourtext text(selectedColour$) wait
|
|
|
Post by StefanPendl on Feb 21, 2012 17:41:02 GMT -5
You could create some static text with a border using CSS and a SPAN tag.
|
|
|
Post by colinmac on Feb 21, 2012 19:21:40 GMT -5
Thanks Stefan, with that I could get the appearence of static text, but not the behaviour.
I wish to be able to programmatically update some text (with a selected name) but not have that update editable by the user. A textbox allows me to update the text (with the #textbox text( name$) method), but how do I prevent the user trying to edit it?
I could not use 'print name$' because that would not print where required. As different names were selected that would appear as a list at the bottom of the page.
It is not a major issue, as the program can ingore the edit, but it would be more intuitive if editing were not allowed.
Colin
|
|
|
Post by StefanPendl on Feb 21, 2012 19:36:41 GMT -5
It might be possible to apply a read-only style through CSS depending on the control type, which you should be able to retrieve by inspecting the web page item using Firebug or a build-in capability of the browser. At www.w3schools.com/ you will find information about the abilities to manipulate the control.
|
|
|
Post by StefanPendl on Feb 21, 2012 19:48:24 GMT -5
This seems to work textbox #t, "hello" html "<script type='text/javascript'> document.getElementById('#t').readOnly=true; </script>" wait
This is based on the information about input controls of type text at w3schools.
|
|
|
Post by StefanPendl on Feb 21, 2012 19:53:29 GMT -5
Your example updated ' textbox thing global #writeout dim colours$(2) colours$(0) = "red" colours$(1) = "green" colours$(2) = "blue" listbox #colourbox, colours$(),1 button #writeout , "confirm colour " , [writeout] print print " this is your favourite colour: " ; textbox #colourtext , " " , 20 html "<script type='text/javascript'> document.getElementById('#colourtext').readOnly=true; </script>" wait
[writeout] selectedColour$= #colourbox selection$() #colourtext text(selectedColour$) wait
BTW, a line-break can be achieved by a single PRINT command too
|
|
|
Post by colinmac on Feb 21, 2012 20:42:14 GMT -5
Thank you Stefan,
That is just what I wanted. Thank you also for you prompt reply. You are a great source of help for this community.
Colin
|
|
|
Post by StefanPendl on Feb 22, 2012 2:31:05 GMT -5
Wrapping the read-only part into a simple procedure: ' textbox thing global #writeout dim colours$(2) colours$(0) = "red" colours$(1) = "green" colours$(2) = "blue" listbox #colourbox, colours$(),1 button #writeout , "confirm colour " , [writeout] print print " this is your favourite colour: " ; textbox #colourtext , " " , 20 call MakeTextBoxReadOnly "#colourtext" wait
[writeout] selectedColour$= #colourbox selection$() #colourtext text(selectedColour$) wait
sub MakeTextBoxReadOnly TextBoxID$ html "<script type='text/javascript'> document.getElementById('"; TextBoxID$; "').readOnly=true; </script>" end sub
|
|
|
Post by meerkat on Feb 22, 2012 8:43:38 GMT -5
You may also consider doing it without a textbox.
' textbox thing dim colours$(2) colours$(0) = "red" colours$(1) = "green" colours$(2) = "blue" listbox #colourbox, colours$(),1 button #writeout , "confirm colour " , [writeout] html "<table border=1 CELLSPACING=0><TR><TD>This is your favoriate colour:></td><td width=40 id=clr></td></tr></table>" html "Your favoriate colour:";"<div id=clr1 style='border:solid 1px;width:300px; height:20px;'>" wait
[writeout] selectedColour$= #colourbox selection$() html "<script> document.getElementById('clr').innerHTML = '";selectedColour$;"';</script>" html "<script> document.getElementById('clr1').innerHTML = '";selectedColour$;"';</script>" wait
|
|
|
Post by colinmac on Feb 27, 2012 7:13:42 GMT -5
Meerkat,
thank you for this posting. Stefan solved my immediate problem. Your code introduced me to a more generalised technique for 'client side' page manipulation which I have now used elsewhere, and has given me some real understanding of how java script works. This is how forums should work.
Colin
|
|