|
Post by marcioc on Aug 31, 2010 20:18:47 GMT -5
I need help from the javascript experts. I am very close to develop a checkbox without submit. It is missing a final detail. I cannot get the value of the box checked after it has been submited. cls link #q,".",[test] html "<script type=""text/javascript""> var a=null; function inform(form,ref,v) { var timer; var as = document.getElementsByTagName('A'); for (var i = 0; i < as.length; i++) { if (as.firstChild.data == ref) { a = as; break; } } if (a) { form.inputbox.value=v; location= a.href; document.myform.submit(); } } </script> "
html "<form name='myform'>" html "<input type='checkbox' name='inputbox' value='Bike' id='vehicle' onclick='inform(this.form,""."",""Bike"")' /> I have a bike<br /> <input type='checkbox' name='inputbox' value='Car' id='vehicle' onclick='inform(this.form,""."",""Car"")' /> I have a car" html "</form>" wait
[test] cls inf$= #request get$("vehicle") print "You clicked ";inf$
|
|
|
Post by StefanPendl on Sept 1, 2010 3:38:29 GMT -5
Is there a reason, you can't use the native RB check box?
|
|
|
Post by marcioc on Sept 1, 2010 8:32:32 GMT -5
In screens that you have to filter information according to previous fields, You have to do this dynamically. For example, many times when you shop through the WEB, and you have to specify in details the product you are shopping, if you do not have the check box generating an event, you have to submit the screen for each option you select in order to be able to update the next options on the screen.
In a strong tool as Run Basic, you have to be more flexible, otherwise it looks like the old IBM mainframe 3272 terminal without the possibility to validate information before you complete the entire screen.
I also do not like WEB Pages that after you introduce zillions of information and submit it, you get a message that field 1 has an error. It could be detected in advance. Many WEB pages has this good functionality.
I am developing this functionality for check box, however my intention is to have on click for any type of field as you have in html.
Thank you for your good question.
|
|
|
Post by marcioc on Sept 1, 2010 8:49:35 GMT -5
Stefan,
Just complementing my answer. Run Basic does not have onclick functionality. I miss it when I program.
Regards.
|
|
|
Post by kokenge on Sept 1, 2010 11:43:53 GMT -5
|
|
|
Post by marcioc on Sept 1, 2010 12:10:55 GMT -5
Uau, sounds like everybody wants events. As you can see in the code I posted, I am very close to get there in a very simple solution. It will allow to use all events supported in HTML just adding a simple java scrip function.
The code already go to any reference in the program when clicked, I am having problem getting the associated information using RB #request get$.
I will continue working in this solution and I will keep you guys informed.
Help from the Javascrip experts will be very welcome.
|
|
|
Post by kokenge on Sept 1, 2010 17:56:02 GMT -5
Just a guess, but I think the reason you don't see the check mark is because the form runs your Run Basic Code again and the first thing it does is clear the screen. Maybe something like this will work.. if firstTime = 0 then firstTime = 1 cls link #q,".",[test] . . . . . wait end if
[test] inf$= #request get$("vehicle") print "You clicked ";inf$ wait
HTH Dan
|
|
|
Post by marcioc on Sept 1, 2010 20:33:07 GMT -5
Good try; unfortunately it did not work.
I believe that the command location = a.ref, clears the values of the variables in the current form. One of the options could be saving the java script variable v in a RB variable before the location = a.ref command, eliminating the command inf$= #request get$("vehicle") in RB code.
I saw some examples in Ajax how to save a java script variable in a PHP variable.
Maybe Carl, who knows the RB guts could give us a tip in how to do this in a RB variable.
Thanks
|
|
|
Post by StefanPendl on Sept 2, 2010 1:23:27 GMT -5
I would still add java script code, that does not change to the head of the page and not the body.
|
|
|
Post by marcioc on Sept 2, 2010 9:46:00 GMT -5
Hi Stefan,
I am sorry, I got a bit confused with your tip. "does not change to the head of the page and not the body". Could you please be more precise.
Thanks in advance
|
|
|
Post by StefanPendl on Sept 2, 2010 15:42:01 GMT -5
The HTML command places things between the <body> tags.
The HEAD command places things between the <head> tags.
|
|
|
Post by marcioc on Sept 5, 2010 11:08:22 GMT -5
Did not work. Thanks anyway. I will keep searching.
|
|