Using GeoLocation variables in CFSET - coldfusion

I'm trying to capture geolocation data and insert it into a database.
The code below is my attempt to capture the browser's longitude and latitude and save the values in two form fields. The problem is the output code generates multiple instances of the two form fields (i.e. "longitude" and "longitude"). Here's a screen shot of a single set of those fields being populated. How do I populate the rest?
Form Code:
<div class="table-responsive">
<table class="table table-1" style="color:##000000">
<tr>
<td>Tree No</td>
<td>Current Status</td>
<td>Graft Successful</td>
<td>NOT Grafted</td>
<td>Graft unsuccessful</td>
<td>Tree Died</td>
</tr>
<cfoutput query="rsTreeList" >
<tr>
<td>#TreeID#</td>
<td>#Status#</td>
<td>
<form name="form1" method="post" action="Recon_Update_Logic1.cfm?ID=#TreeID#">
<img src="images/Icons/Success.jpg" width="25" height="25" alt=""/>
<input id="latitude" name="latitude" type="text" />
<input id="longitude" name="longitude" type="hidden" />
<input name="submit" type="submit" id="Submit" value="Graft Successful">
</form>
</td>
<td>
<form name="form1" method="post" action="Recon_Update_Logic2.cfm?ID=#TreeID#">
<img src="images/Icons/NotGrafted.jpg" width="25" height="25" alt=""/>
<input id="latitude" name="latitude" type="text" />
<input id="longitude" name="longitude" type="hidden" />
<input name="submit" type="submit" id="Submit" value="NOT Grafted">
</form>
</td>
<td>
<form name="form1" method="post" action="Recon_Update_Logic3.cfm?ID=#TreeID#">
<img src="images/Icons/GraftUnsuccessful.jpg" width="25" height="25" alt=""/>
<input id="latitude" name="latitude" type="hidden" />
<input id="longitude" name="longitude" type="hidden" />
<input name="submit" type="submit" id="Submit" value="Graft Unsuccessful">
</form>
</td>
<td>
<form name="form1" method="post" action="Recon_Update_Logic4.cfm?ID=#TreeID#">
<img src="images/Icons/TreeDead.jpg" width="25" height="25" alt=""/>
<input id="latitude" name="latitude" type="hidden" />
<input id="longitude" name="longitude" type="hidden" />
<input name="submit" type="submit" id="Submit" value="Tree Dead">
</form>
</td>
</tr>
</cfoutput>
</table>
</div>
The following code attempts to populate all of the "latitude" and "longitude" elements:
<cfloop index="i" from="1" to="#rsTreeList.recordCount#">
<script>
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position)
{
document.getElementById("latitude").value = position.coords.latitude;
document.getElementByID("longitude").value = position.coords.longitude;
}
getLocation();
</script>
</cfloop>

Related

TR, TH, TD was created but TABLE NOT

i Need understand it but not be able to.
My ClassForm (in view):
class FormContact(forms.Form):
name = forms.CharField(label='Nome', max_length=100, required=False)
subject = forms.CharField(label='Assunto', max_length=100, required=False)
message = forms.CharField(label='Mensagem', widget=forms.Textarea, required=False)
My extended Template:
{% extends 'site.html' %}
{% load static %}
{% block content %}
<form class="contato" id="contato" action="{% url 'contato' %}" method="post">
<h1>Contato</h1>
{% csrf_token %}
{{ form }}
<input type="submit" value="Submit">
</form>
<script src="{% static 'js/form_contact.js' %}"></script>
{% endblock %}
Now,
in the navigator (inspector -> elements)
<form class="contato" id="contato" action="/contato/" method="post">
<h1>Contato</h1>
<input type="hidden" name="csrfmiddlewaretoken" value="???">
<label for="id_name">Nome:</label>
<input type="text" name="name" maxlength="100" id="id_name">
<label for="id_subject">Assunto:</label>
<input type="text" name="subject" maxlength="100" id="id_subject">
<label for="id_message">Mensagem:</label>
<textarea name="message" cols="40" rows="10" id="id_message"></textarea>
<input type="submit" value="Submit">
/form>
AND, in the navigator (Ctrl+U) View Code
<form class="contato" id="contato" action="/contato/" method="post">
<h1>Contato</h1>
<input type="hidden" name="csrfmiddlewaretoken" value="????">
<tr>
<th><label for="id_name">Nome:</label></th>
<td>
<input type="text" name="name" maxlength="100" id="id_name">
</td>
</tr>
<tr>
<th><label for="id_subject">Assunto:</label></th>
<td>
<input type="text" name="subject" maxlength="100" required id="id_subject">
</td>
</tr>
<tr>
<th><label for="id_message">Mensagem:</label></th>
<td>
<textarea name="message" cols="40" rows="10" required id="id_message"></textarea>
</td>
</tr>
<input type="submit" value="Submit">
</form>
My doubt is:
Why, in the Ctrl+U, was created the elements TR, TH and TD but TABLE not?
I can't understand it
It is this form same?

Django form in a table can't get right parameters

<tbody>
{% for sec in sec_list %}
<tr>
<td>{{sec.c_id_id}}.{{sec.sec_id}}</td>
<td>{{sec.title}}</td>
<td>{{sec.name}}</td>
<td>{{sec.time}}</td>
<td>{{sec.r_no_id}}</td>
<td>{{sec.cur}}/{{sec.capcity}}</td>
<td><form method="post" role="form" action="">
{% csrf_token %}
<input class="hidden" type="submit" value="{{sec.c_id_id}}.{{sec.sec_id}}" name="course" id="course">
<input class="hidden" type="submit" value="{{sec.cur}}" name="num" id="num">
<input class="hidden" type="submit" value="{{sec.capcity}}" name="limit" id="limit">
<p class="form-action">
<input type="submit" value="选课" class="btn btn-link">
</p>
</form></td>
</tr>
{% endfor %}
</tbody>
I want to use a hidden form to transfer some parameters in a table.My code is above.But when I use
request.POST.get("limit",'')
,I got a null one.How to fix it
edit your html code by replacing the type="submit" to type="hidden",
<td><form method="post" role="form" action="">
{% csrf_token %}
<input class="hidden" type="hidden" value="{{sec.c_id_id}}.{{sec.sec_id}}" name="course" id="course">
<input class="hidden" type="hidden" value="{{sec.cur}}" name="num" id="num">
<input class="hidden" type="hidden" value="{{sec.capcity}}" name="limit" id="limit">
<p class="form-action">
<input type="submit" value="选课" class="btn btn-link">
</p>
</form></td>
Shouldn't those inputs be type=hidden instead of class=hidden?
<input type="hidden" value="{{sec.capcity}}" name="limit" id="limit">
The type=submit in all of them makes no sense to me as it is supposed to be used only in submit buttons.

Why doesn't robobrowser return the page source after login?

I am trying to automate login process in a website using robobrowser. here is the code:
browser = RoboBrowser()
login_url = 'https://fiitjeelogin.com'
post_login = 'https://fiitjeelogin.com/StudentDashboard.aspx?UserdID=1110611570024&BatchCode=MDIT57T04,%20MDIT57F05,%20MDIT57R05&CenterCode=61'
eventval = '/wEdAAl1eLz1ChyMlpOH84l9DXRBKhoCyVdJtLIis5AgYZ/RYe4sciJO3Hoc68xTFtZGQEg/Lx6HO3zp5MHCG49Y5hGYd39wMEiroGigGt6l+80X6qoJzVbh9uRjatIO8j62gEVUrsGtEC0SKq72cYUQj6MH2BaA8epCgZlCbUaqFyjHLgdkZW6ckU2fp2bSHM106Q/CZwerK9DhufKPKISNnwtBsTsTMrfob//+ZrYm6E/+LQ=='
viewstat = '/wEPDwUJOTI4MjgwNjQwD2QWAgIDD2QWAgIPD2QWAgIBD2QWAmYPZBYGAgMPFgIeB1Zpc2libGVoZAILDxYCHwBoZAINDw8WAh4EVGV4dAUEU2VuZGRkZFRRYynlwFTooznce3Y+ZTEmDUGkCBVmcuPXOfi78tSc'
browser.open(login_url)
form = browser.get_form(id = 'ctl01') #choosing matching form id
form['username'].value = 'username'
form['password'].value = 'password'
form['__VIEWSTATEGENERATOR'].value = 'C8125695' #constant
form['__EVENTVALIDATION'].value = eventval
form['__VIEWSTATE'] = viewstat
form['txtUsername'] = ''
form['txtemailid'] = ''
b_e_arg = '\<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" \/\>'
a = robobrowser.forms.fields.Input(b_e_arg) #assigning this using form['__EVENTARGUMENT'] gave a 400 BAD REQUEST...same for EVENTTARGET
b_e_target = '\<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" \/\>'
b = robobrowser.forms.fields.Input(b_e_target)
form.add_field(a)
form.add_field(b)
b_e_btn = '\<input class="buttonb" id="btnlogin" name="btnlogin" type="submit" value="Log in"\/\>'
c = robobrowser.forms.fields.Input(b_e_btn)
form.add_field(c)
submit_here = form['btnlogin']
submit_here.value = 'Log+in'
browser.submit_form(form, submit = submit_here)
alltext = browser.parsed
print alltext
Now, the login form takes the following inputs as seen by Firefox Debugging:
__EVENTTARGET,
__EVENTARGUMENT,
__VIEWSTATE,
__VIEWSTATEGENERATOR,
__EVENTVALIDATION, username, password, btnlogin, txtUsername, txtemailid,
The values for __VIEWSTATEGENERATOR , __EVENTVALIDATION , __VIEWSTATE do not change.
The code returns the HTML of the login page whereas I expect the HTML of the page after logging in.
I have tried this and from this
Here's the HTML of the Login Page:
<body>
<form method="post" action="" id="ctl01">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJOTI4MjgwNjQwD2QWAgIDD2QWAgIPD2QWAgIBD2QWAmYPZBYGAgMPFgIeB1Zpc2libGVoZAILDxYCHwBoZAINDw8WAh4EVGV4dAUEU2VuZGRkZFRRYynlwFTooznce3Y+ZTEmDUGkCBVmcuPXOfi78tSc" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['ctl01'];
if (!theForm) {
theForm = document.ctl01;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="C8125695" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAl1eLz1ChyMlpOH84l9DXRBKhoCyVdJtLIis5AgYZ/RYe4sciJO3Hoc68xTFtZGQEg/Lx6HO3zp5MHCG49Y5hGYd39wMEiroGigGt6l+80X6qoJzVbh9uRjatIO8j62gEVUrsGtEC0SKq72cYUQj6MH2BaA8epCgZlCbUaqFyjHLgdkZW6ckU2fp2bSHM106Q/CZwerK9DhufKPKISNnwtBsTsTMrfob//+ZrYm6E/+LQ==" />
</div>
<fieldset style="border-color: #95B3d7; border-bottom: 0px; border-right: 0px; border-top: 0px;
border-left: 0px; padding-left: 10px">
<legend style="color: #365f91; font-weight: bold; font-family: Calibri; font-size: 15px">
Already Registered</legend>
<p>
<img src="StartpageImage/LoginLock.png" style="width: 130px; height: 130px" />
</p>
<div class="row">
<section class="col col-8">
<label class="label" style="color:#3698db ;font-family:Calibri">User Name</label><br />
<label class="input">
<input name="username" type="text" id="username" class="Jaitextbox" />
</label>
</section>
<section class="col col-8">
<label class="label" style="color:#3698db ;font-family:Calibri">Password</label><br />
<label class="input">
<input name="password" type="password" id="password" class="Jaitextbox" />
</label><br />
<p align="right" style="margin-right:100px;"><a id="lnkforgetpassword" href="javascript:__doPostBack('lnkforgetpassword','')" style="color:#F79646;color:#f79646 ;font-family:Calibri">Forgot Password?</a></p>
</section>
</div>
<input type="submit" name="btnlogin" value="Log in" id="btnlogin" class="buttonb" />
</div>
<div class="body">
<div id="updatpanelforgetpass">
<table>
<tr id="trDisp1">
<td colspan="2">
<h3 align="center" style="color: #365f91; font-family: Calibri; font-weight: bold">
<u>Forgot Password</u></h3>
</td>
</tr>
<tr id="trDisp3">
<td colspan="2">
Please provide registered User Name or EmailId with Fittjee
</td>
</tr>
<tr id="trDisp4">
<td>
<span id="lblUsername" style="color: #3698db; font-family: Calibri">UserName :</span>
</td>
<td>
<input name="txtUsername" type="text" id="txtUsername" class="Jaitextbox" /></p>
</td>
</tr>
<tr id="trDisp5">
<td>
<span id="lblemailid" style="color: #3698db; font-family: Calibri">EmailID :</span>
</td>
<td>
<input name="txtemailid" type="text" id="txtemailid" class="Jaitextbox" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="btnPass" value="Send" id="btnPass" class="buttonb" />
</td>
<div id="ValidationSummary1" class="error" style="display:none;">
</div>
<span id="lblMessage" style="color:Red;"></span>
</tr>
</table>
</div>
</div>
</div>

How to transfer changed content into plone theme with diazo?

Now I need the following search structure in the theme:
<div class="sideCol">
<aside class="siteSearch">
<form name="searchform" action="search" class="searchPage searchform" id="searchform">
<fieldset>
<legend>Website durchsuchen</legend>
<input class="searchPage text lang-de" name="SearchableText" type="text" size="25" title="Website durchsuchen" value="" placeholder="Suchbegriff..." />
<button type="submit"><i class="icon-search"></i></button>
</fieldset>
</form>
</aside>
</div>
All I need to get from Plones sunburst theme is the action link for the form element.
So I tried this:
<replace css:content-children="#portal-searchbox">
<xsl:variable name="action_link" select="form/#action" />
<form name="searchform" action="search" class="searchPage searchform" id="searchform">
<xsl:attribute name="action">${action_link}</xsl:attribute>
<fieldset>
<legend>Website durchsuchen</legend>
<input class="searchPage text lang-de" name="SearchableText" type="text" size="25" title="Website durchsuchen" value="" placeholder="Suchbegriff..." />
<button type="submit"><i class="icon-search"></i></button>
</fieldset>
</form>
</replace>
<replace css:content-children="#portal-searchbox" css:theme-children=".siteSearch" />
The problem ist that all I get in the theme is the structure of Plones Sunburst Search.
<div class="sideCol">
<aside class="siteSearch">
<form id="livesearch0" action="http://localhost:8080/mamuz/de/##search">
<div class="LSBox">
<label class="hiddenStructure" for="searchGadget">Website durchsuchen</label>
<input name="SearchableText" type="text" size="18" title="Website durchsuchen" placeholder="Website durchsuchen" accesskey="4" class="searchField" id="searchGadget" autocomplete="off">
<input class="searchButton" type="submit" value="Suche">
<div class="searchSection">
<input id="searchbox_currentfolder_only" class="noborder" type="checkbox" name="path" value="/mamuz/de/impressum">
<label for="searchbox_currentfolder_only" style="cursor: pointer">nur im aktuellen Bereich</label>
</div>
<div class="LSResult" id="LSResult">
<div class="LSShadow" id="LSShadow"></div>
</div>
</div>
</form>
<div id="portal-advanced-search" class="hiddenStructure">
Erweiterte Suche…
</div>
</aside>
</div>
I'm familiar with diazo but pretty new to xslt. What is wrong? I tired several types of placements like import before it gets modified. Nothing helps.
Using the replace directive on attribute itself should work:
<replace attributes="action"
css:content="#portal-searchbox form"
css:theme="#searchform" />

Remember radio button selection in Django

Without using javascript, is there a better way to remember a user's radio button selection? I feel I have a pretty naive(?) way of doing it?
How can I re-write this to make it more DRY? usersegment parem gets returned on the same page upon submit.
{% if usersegment == "non-paying" %}
<input type="radio" name="usersegment" value="non-paying" checked="yes"/> Non-paying Users <br />
<input type="radio" name="usersegment" value="paying" /> Paying Users <br />
<input type="radio" name="usersegment" value="all" /> All Users<br />
{% endif %}
{% if usersegment == "paying" %}
<input type="radio" name="usersegment" value="non-paying" /> Non-paying Users <br />
<input type="radio" name="usersegment" value="paying" checked="yes"/> Paying Users <br />
<input type="radio" name="usersegment" value="all" /> All Users<br />
{% endif %}
{% if usersegment == "all" or not usersegment %}
<input type="radio" name="usersegment" value="non-paying" checked="yes"/> Non-paying Users <br />
<input type="radio" name="usersegment" value="paying" /> Paying Users <br />
<input type="radio" name="usersegment" value="all" checked="yes"/> All Users<br />
{% endif %}
How about this:
<input type="radio" name="usersegment" value="non-paying" {% if usersegment == "non-paying" %}checked="checked"{% endif %}/> Non-paying Users <br />
<input type="radio" name="usersegment" value="paying" {% if usersegment == "paying" %}checked="checked"{% endif %}/> Paying Users <br />
<input type="radio" name="usersegment" value="all" {% if usersegment == "all" or not usersegment %}checked="checked"{% endif %}/> All Users<br />
Also, consider using django forms. Trivial problems like those are solved in a very elegant way there, you don't even need to think about it.