|
Post by mikegann on Oct 15, 2008 12:51:40 GMT -5
I found an example of a date picker which I want to add to my application. However I have two questions. 1. How to get the selected date into a Run Basic variable 2. How to align all the textareas, listboxs, and date picker. I would like to have all their tops horizonally aligned. Here is an example:
HTML "<script language=""javascript"" type=""text/javascript"" " HTML "src=""http://localhost:8008/resources/JS/datetimepicker.js"">" HTML "</script>"
Dim users$(1) users$(0)="MG" users$(1)="BB" Dim status$(1) status$(0)="Open" status$(1)="Closed"
Print "Add New Project" Print "" textarea #customer,"",15,2 textarea #partnumber,"",10,2 textarea #description,"",15,2 textarea #summary,"",35,4 listbox #UserSelect,users$(),1
HTML "<input id=""date"" type=""text"" size=""10""><a href=""javascript:NewCal('date','mmddyyyy')""><img src=""http://localhost:8008/resources/cal.gif"" width=""16"" height=""16"" border=""0"" alt=""Pick a date""></a>"
listbox #status,status$(),1
'Date Time Picker script- by TengYong Ng of www.rainforestnet.com 'Script featured on JavaScript Kit (http://www.javascriptkit.com) 'For this script, visit www.javascriptkit.com
|
|
|
Post by mikegann on Oct 17, 2008 16:37:24 GMT -5
I figured out how to get the date from the javascript date picker into a runbasic text area. I used SetID to assign the ID of the html date ID to a runbasic textarea handle. It seems that the handle you use must be defined before the html statement. In the html input statment I also changed type=text to type=hidden so the html doesn't display its own text box. I hope this helps someone. I am not familiar enough to explain this better. It was quite a bit of trial and error for me to figure it out. The actual javascript can be downloaded from the site referenced in the comments in the code window below.
HTML "<script language=""javascript"" type=""text/javascript"" " HTML "src=""http://localhost:8008/resources/JS/datetimepicker.js"">" HTML "</script>"
'Date Time Picker script- by TengYong Ng of www.rainforestnet.com 'Script featured on JavaScript Kit (http://www.javascriptkit.com) 'For this script, visit www.javascriptkit.com
textarea #duedate,"",10,1
HTML "<input id=""date"" type=""hidden"" size=""10""><a href=""javascript:NewCal('date','mmddyyyy')""><img src=""http://localhost:8008/resources/cal.gif"" width=""16"" height=""16"" border=""0"" alt=""Pick a date""></a>"
Print"" Print"" textbox #Date,""
#duedate setid("date") link #GetDate,"Get Date from Textarea",[GetDate] wait
[GetDate] a$=#duedate contents$() #Date text(a$) wait
|
|
|
Post by kokenge on Oct 17, 2008 18:23:49 GMT -5
I have an example of a Date and Time picker that is written in Run Basic. If you want to see it go to www.dkokenge.com/rbp and select "calendar" . If you login with admin/admon you can then select 'Chg' to change a schedule,and it will show you the date picking routine. Don't worry about changing anything, it's strictly a test system. To the right of the data is a button [?] that will pop up a date picker for the month and year you have selected. You can then pick the date and it will return it to the day drop down. It would have been just as easy to make it a single date field. I looked at many of the JS routines, and decided it was a lot easier to have everything in RB. Hope this helps.
|
|
|
Post by kokenge on Oct 18, 2008 8:00:17 GMT -5
I was ask by a couple people if I could post the Run Basic Date picker. It would look better if it were a little smaller. However you cannot use special characters in a ID field, so you must use buttons instead of links.
Here is a sample working date program..
mths$ = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" sqliteconnect #mem, ":memory:" ' make in memory db #mem execute("SELECT strftime('%Y-%m-%d','now')") today$ = #mem nextrow$("")
gosub [getMonthInfo] ' find days in month and begin month day of week
' user interface screen html "<table><TR><TD>" textbox #dte,today$,10 #dte setid("dte") button #ssd, "?", [datePicker] #ssd setkey(today$) html "</TD><TD id='popDate'></TD></TR></TABLE>" wait
' --------------------------------------------- ' Date Picker ' --------------------------------------------- [datePicker] a$ = EventKey$ yr = val(word$(a$,1,"-")) mm = val(word$(a$,2,"-"))
[picket] gosub [getMonthInfo] x = 0 html "<script> document.getElementById('popDate').innerHTML = '" html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat><TR>" html "<TD colspan=7 align=center>" button #back,"<",[back] html " ";word$(mths$,mm,",");" ";yr;" " button #fwd,">",[fwd] html "</TD></TR>" for i = 1 to mmDays + dow if i > dow then x = x + 1 if x = 0 then html "<td></td>" else html "<TD>" button #sd,str$(x),[sd] #sd setkey(x) html "</TD>" end if if (i mod 7) = 0 then html "</TR><TR>" next i html "</TR></table>" html "';</script>" wait
' back a month [back] mm = mm - 1 if mm < 1 then mm = 12 yr = yr - 1 end if goto [picket]
' forward a month [fwd] mm = mm + 1 if mm > 12 then mm = 1 yr = yr + 1 end if goto [picket]
' select date [sd] dd$ = right$("0";EventKey$,2) mm$ = right$("0";mm,2) html "<script> document.getElementById('dte').value = '";yr;"-";mm$;"-";dd$;"';</script>" wait
[getMonthInfo] ' ---------------------------------------- ' day of week when month begins. ' days in a month ' ---------------------------------------- if yr < 100 then yr = val(date$("yy")) if mm < 1 or mm > 12 then mm = val(date$("mm")) dayOne$ = str$(yr) ; "-" ; right$("0";str$(mm),2) ; "-01" sql$ = "SELECT strftime ( '%w','";dayOne$;"') as dow, date('";dayOne$;"','start of month','+1 month','-1 day') as emo" #mem execute(sql$) result$ = #mem nextrow$(" |") dow = val(word$(result$,1,"|")) ' Day of Week month begins eom$ = trim$(word$(result$,2,"|")) ' End of month mmDays = val(word$(eom$,3,"-")) ' Days in Month
RETURN
|
|