|
Post by Jerry Muelver on Oct 1, 2007 17:37:24 GMT -5
(Reposted by Admin who accidentally deleted the original posting....)
' brent, Run BASIC forum, 2007.09.15 ' The following demo shows how to make a form with ' Submit and Reset buttons. The Reset is easily done ' with one line of HTML. The Submit requires some ' Javascript to first copy the functionality of a ' link and then replaces the link where it sits. ' ' Be aware, this code replaces all links made using LINK with buttons.
Cls Print "Username: "; TextBox #u, "" Print Print "Password: "; PasswordBox #p, "" Print ' the link acts as a placeholder and will be replaced by the submit button Link #a, "Submit", [Login] ' create a reset button HTML "<input type=""reset"" />" ' now the complicated part HTML " <script type=""text/javascript""> <!-- var as = document.getElementsByTagName('A'); // get all A's for ( var i = 0; i < as.length; i++ ) { // and iterate thru them all if ( as[i].onclick ) { // looking for those with onclick // event handlers var el = document.createElement('INPUT'); // create an input el.type = 'submit'; // and make it a submit button el.onclick = as[i].onclick; // copy the event handler el.value = as[i].firstChild.data; // get button's text from the link as[i].parentNode.replaceChild(el, as[i]); // finally replace the link } } //--> </script>" ' Wait ' [Login] u$ = #u Contents$() p$ = #p Contents$() ' Cls Print "Username: "; u$ Print "Password: "; p$ Print "All done!" ' End
|
|
|
Post by Jerry Muelver on Oct 1, 2007 17:40:22 GMT -5
The CODE tag collapses spaces, making for not-so-pretty code. My apologies. Don't we have a fix for this problem?
|
|
Chris Iverson
Junior Member
There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73
|
Post by Chris Iverson on Oct 1, 2007 21:43:43 GMT -5
We do on the LB Conforums, would that work here? I remember having a similar problem there, until someone(I think it was Alyce) came up with a fix.
|
|
|
Post by StefanPendl on Oct 2, 2007 0:40:34 GMT -5
remove the & n b s p fix from the censored words list, code is formatted properly without it.
|
|
|
Post by carlgundel on Oct 2, 2007 6:26:43 GMT -5
That's a cool bit of meta-javascript programming, but it sure is a lot of code. Wouldn't this suffice?
-Carl
[reset] Cls Print "Username: "; TextBox #u, "" Print Print "Password: "; PasswordBox #p, "" Print Link #a, "Submit", [Login] print " "; link #b, "Reset", [reset] Wait
[Login] u$ = #u Contents$() p$ = #p Contents$()
Cls Print "Username: "; u$ Print "Password: "; p$ Print "All done!" End
|
|
|
Post by carlgundel on Oct 2, 2007 9:17:56 GMT -5
That's a cool bit of meta-javascript programming, but it sure is a lot of code. Wouldn't this suffice? Geesh, what am I complaining about? The code is very instructive, and I can hopefully learn a lot about how to improve Run BASIC by looking at stuff like that. Keep it coming! -Carl
|
|
|
Post by Brent on Oct 2, 2007 12:32:05 GMT -5
|
|
|
Post by carlgundel on Oct 2, 2007 13:57:04 GMT -5
Yes, I agree. I'm not sure why it is actually absolutely necessary since you can use links for this and if you don't like the way links look you can even pretty them up with a little CSS, but it is very useful to see some small javascript examples. -Carl
|
|
|
Post by Brent on Jan 18, 2008 21:22:04 GMT -5
|
|
|
Post by carlgundel on Jan 18, 2008 22:14:49 GMT -5
Wow! That's great. But, you posted as a reply to the wrong thread! THANK YOU! -Carl
|
|
|
Post by carlgundel on Jan 18, 2008 22:23:20 GMT -5
Is this what you're looking for? [get point]
x = #x value() y = #y value()
'cls print "You clicked the map at (";x;", ";y;")." wait I changed the [get point] handler to wait instead of ending the program, and I commented out the CLS. I was hoping that I could click multiple times at different places on the image, but it only ever returns the coordinates from the first click. Is there an easy fix for this? Thanks (so much)! -Carl
|
|