Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

HTML WebPage CheckBoxes and OptionBoxes


steveg Jul 9, 2013 08:07 AM

Dear All,

I am working on some CR1000 served webpages in which I would like some simple user interactivity to be provided.
I have seen the InputBox example by Dana, and can follow it, but am having trouble extending this to CheckBoxes, especially those which are representing arrays of boolean values.

In this example I am interested in the array of boolean values named Do15Sec(w) (where w is from 1 to 39). They are a series of switches to indicate whether certain sensors should be measured or not.

I'd like to be able to switch activity for them on and off via this webpage.

See below for the code that I have so far.
I get a very messy (but correct-ish looking) GET string in the address bar when I submit it, but no changes to logger variables.

I suspect my code has a chance of working when setting values for true, but am concerned that I may not be able to set the back to false as easily...

One final, 'nice to have' is to ask whether POST submission is possible in this way. Or is the process limited to GET ...?


Looking forward to your interest and assistance. Thanks in advance.

Best Regards,

Steve
Sydney, Australia


WebPageBegin ("setup.html",Commands)
HTTPOut("<!DOCTYPE HTML PUBLIC " + CHR(34) + "-//W3C//DTD HTML 4.0 Transitional//EN" + CHR(34)+ ">")
HTTPOut("<html>")
HTTPOut("<head>")
HTTPOut("<title>Restressing - SETUP</title>")
HTTPOut("</head>")
HTTPOut("<body>")

'
HTTPOut("<form action=" + CHR(34) + CHR(34) +">" + CHR(13))
'
'hidden form elements
HTTPOut("<input type='hidden' name='command' value='SetValue'>" + CHR(13)) 'element to SetValues
HTTPOut("<input type='hidden' name='table' value='public'>" + CHR(13)) 'element to indicate table to update

'
HTTPOut("<input type='submit' value='Apply'>" + CHR(13))
'
HTTPOut("<table border=" + CHR(34) +"1" + CHR(34) +">" + CHR(13))
HTTPOut("<tr> <th> Index </th> <th> KM </th> <th> SN String</th> <th>15 Sec Active</th> </tr>" + CHR(13))
For w = 1 To 39 'load all devices, but only if SNstring and? KM is non-empty
'make table of indexes, kms, SNStrings and activity status indicated by checkboxes

HTTPOut("<input type='hidden' name='field' value='Do15Sec("+w+")'>" + CHR(13))
If Do15Sec(w) Then : CheckedString = "checked" : Else : CheckedString = "" : EndIf
HTTPOut("<tr> <th>" + w + "</th> <th>" + "kms" + "</th> <th>" + "pollstring" + "</th> <th>" + "<input type="+ CHR(34) + "checkbox"+ CHR(34) + " name="+ CHR(34) + "Do15Sec("+w+")" + CHR(34) + " value="+ CHR(34) + "true"+ CHR(34) + " " + CheckedString + ">" + " </th> </tr>" + CHR(13))
Next w
HTTPOut("</table>" + CHR(13))
'
HTTPOut("</form>" + CHR(13))
HTTPOut("<br>")

HTTPOut("</body>")
HTTPOut("</html>")
WebPageEnd

* Last updated by: steveg on 7/9/2013 @ 2:10 AM *


Dana Jul 9, 2013 06:58 PM

I don't want to come across as trying to "sell anything", but this is a lot easier now if you use RTMC Pro to create a project, and publish that project to the datalogger (ends up as javascript).

My HTML knowledge is limited, so I can be of no help regarding the check boxes. Regarding Post rather than Get, the latest CR1000 OS now has HTTPPost and HTTPPut - I don't know if this is what you are after...

Dana W.


steveg Jul 9, 2013 11:48 PM

Hi Dana,

Thanks for your response.

I am downloading the RTCM Pro trial at the moment and will play around with it today. I realise there is a fine line between 'selling' and 'informing your customers'. In this case I am glad you have. Sometimes it is hard to keep up with everything you have on offer without reading every manual every six months...!

As for POST vs GET, I'm thinking of it the other way around. i.e. the browser on my PC/phone needs to POST to the CR1000. From my (also) limited knowledge of HTML, POST essentially hides the transmission and GET is the process of sending information to the webserver (in this case the CR1000) via a lengthy URL. Both have benefits and disadvantages.

I'll keep working on this in my own time, and if I come up with something I will post to the group. Are there any resources in addition to CRBasic Help that I can get a hold of? Even some more examples might make it click for me.

Best Regards,

Steve

Log in or register to post/reply in the forum.