|
|
Thank you.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I'm working on a task where given the coordinates of a line from point A to point B, I need to create a polygonal geofence around(50meters) this line (road route) in google maps.
Can some one help with this?
|
|
|
|
|
|
|
Please, I am using two javascript files, which has its own assigned worked, on a php page, however the jquery script stops working while the JSON2 script works.
This is how I implement both on the php page
<script type="text/javascript" src="jquery.min.js" ></script>
<script type="text/javascript" src="JSON2.js" ></script>
The link to the jquery file http://code.jquery.com/jquery-1.11.1.min.js
The link to JSON2.js :
https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js
**Question**
Please, is it possible to use both script on the same page? if yes, please how to I go about it?
Thanks for helping.
|
|
|
|
|
I'm unaware of any issues using the 2 together. It would help if you could tell us what is happening.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
This is what i see in my web console log
SyntaxError: JSON.parse: unexpected character , this is found in th json.js
TypeError: Q[a].exec is not a function , this is also found in the jquery.js
|
|
|
|
|
Does your code have errors?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi, i think i have solved it,I was previously using json and now i have to changed it to json2
|
|
|
|
|
I have this list of items in a div container, so each item has it's own container. It's a long list of previous orders, a ticket list on the left.
You can click on the container, and the background-color will change, and it will fire a function that accesses a web service, and create a ticket for the item on the right.
LEFT SIDE | RIGHT SIDE
ORDERS | ORDER TICKET PREVIEW
I want to disable the click on the left, the orders, while the ticket on the right is created, so dumb users don't click the thing to death.
I'm not sure how to go about this one, looking for ideas. I wrote it in Javascript, with a little jQuery mixed in.
I was looking for a neat clean way to do this, without globals and chopping it up. I can't see how I can recreate the complex onclick to enable it again, and don't understand what happens to the vars I pass.
Perhaps I can somehow disable the whole container from the click, preserving the underlying click.
So this runs in a for loop, and creates a container for each previous order, with order data inside it.
Hope I was able to convey my thoughts here clearly.
function build COH_List() {
var div_item_container = document.createElement('div');
div_item_container.id = m_ID;
div_item_container.className = 'div_item_container';
div_item_container.style.width = '100%';
div_item_container.style.height = '42px';
div_item_container.style.margin = '3px 0px';
div_item_container.style.borderBottom = "dotted 1px rgb(200,200,200)";
div_item_container.style.display = 'block';
div_item_container.style.cssFloat = 'clear';
div_item_container.onclick = (function (m_ID, m_orderID, m_orderNumber, m_orderDate) { return function () { select_order_click(m_ID, m_orderID, m_orderNumber, m_orderDate); }; })(m_ID, m_orderID, m_orderNumber, m_orderDate);
div_items_container.appendChild(div_item_container);
And then I have a function below that builds the order ticket.
function load_orderDetails() {
}
|
|
|
|
|
have you tried...
element.onclick = '';
maybe write your handler like so.
function load_orderDetails(ele) {
ele.onclick = '';
}
just make sure when you call it you pass it the element that you want disabled. just by chance are you using jQuery because there are message handlers that will do this for you??
|
|
|
|
|
I'll give that that a try later today. Good Idea!
Will let you know the outcome.
|
|
|
|
|
You can use the CSS property pointer-events to disable the click event on any element:
https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
// To disable:
document.getElementById('id').style.pointerEvents = 'none';
// To re-enable:
document.getElementById('id').style.pointerEvents = 'auto';
// Use '' if you want to allow CSS rules to set the value
see more here[^]
|
|
|
|
|
Please I am a newbie to Jquery and javascript however I am trying to parse a table name from jquery to a php page which which will be used to truncate a table.
Please below is what I have tried so far...
Jquery page
$(function() {
$.winFocus(function(event, isVisible) {
if(isVisible){
var tableName="table1";
$("#isVisible").val(tableName);
}
else {
var tableName = "table2";
$("#isVisible").val("tableName");
}
});
})
The PHP form
//table name value from jquery
$tableName ='';
// mysql query that truncates the table
$query = "TRUNCATE TABLE $tableName";
This does not give any error,yet it doesnt truncate the table. Please what am I doing wrong?
Thanks for helping.
|
|
|
|
|
If you debug it you should be able to find what's happening.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi...
I am creating web application using Netbeans and Mysql .
I created page to Save, Update & Delete marathi or hindi Language data to my database ... but facing problem with page and database for insert and view data
if i save तुषार ,,,,
database showing me तà¥à¤·à¤¾à¤°
Please help me
|
|
|
|
|
|
I think you should use NVARCHAR data type to store this data into SQL.
|
|
|
|
|
Experts,
Can someone please help me resolve this problem?
When a user selects start time and end time, if the difference in hours is not at least 4 hours, an alert should be raised.
This works beautifully with asp.net web form.
However, I had to switch to Gridview because I wanted not just the ability to dynamically add more dates as needed, but also be able to submit user's choices to the database.
So, since switching to gridview, the validation is no longer working.
Can someone please give me a helping hand?
Thanks a lot in advance.
<script type="text/javascript">
$(function () {
$("[id$=txtdate]").datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: 'images/20/calendar200.gif'
});
});
</script>
<script type='text/javascript'>
$(window).load(function () {
$('#btnSave').on('click', function () {
var sHour = $('#startHour').val();
var sMinutes = $('#startMinutes').val();
var sAmPm = $('#startAmPm').val();
var eHour = $('#endHour').val();
var eMinutes = $('#endMinutes').val();
var eAmPm = $('#endAmPm').val();
var theDate = $('#txtdate').val()
var timeStart = new Date(theDate + ' ' + sHour + ':' + sMinutes + ' ' + sAmPm).getHours();
var timeEnd = new Date(theDate + ' ' + eHour + ':' + eMinutes + ' ' + eAmPm).getHours();
var hourDiff = timeEnd - timeStart;
if (hourDiff < 4) {
alert("A mininum of 4 hours is required!");
}
});
});
</script>
Then markup
<asp:gridview ID="Gridview1" runat="server" OnRowDeleting="Gridview1_RowDeleting" ShowFooter="true" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Event Date(s)">
<ItemTemplate>
<asp:TextBox ID="txtdate" runat="server" class = "Calender"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtdate"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Start Time">
<ItemTemplate>
<asp:DropDownList id="startHour" runat="server">
<asp:ListItem Value="07">07</asp:ListItem>
<asp:ListItem Value="08">08</asp:ListItem>
<asp:ListItem Value="09">09</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Selected="True" Value="12">12</asp:ListItem>
<asp:ListItem Value="01">01</asp:ListItem>
<asp:ListItem Value="02">02</asp:ListItem>
<asp:ListItem Value="03">03</asp:ListItem>
<asp:ListItem Value="04">04</asp:ListItem>
<asp:ListItem Value="05">05</asp:ListItem>
<asp:ListItem Value="06">06</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="startHour"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Minutes">
<ItemTemplate>
<asp:DropDownList id="startMinutes" runat="server">
<asp:ListItem Value="00">00</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="30">30</asp:ListItem>
<asp:ListItem Value="45">45</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="startMinutes"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AM/PM">
<ItemTemplate>
<asp:DropDownList id="startAmPm" runat="server">
<asp:ListItem Value="AM">AM</asp:ListItem>
<asp:ListItem Value="PM">PM</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="startAmPm"
ErrorMessage="*"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="End Time">
<ItemTemplate>
<asp:DropDownList id="endHour" runat="server">
<asp:ListItem Value="07">07</asp:ListItem>
<asp:ListItem Value="08">08</asp:ListItem>
<asp:ListItem Value="09">09</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Selected="True" Value="12">12</asp:ListItem>
<asp:ListItem Value="01">01</asp:ListItem>
<asp:ListItem Value="02">02</asp:ListItem>
<asp:ListItem Value="03">03</asp:ListItem>
<asp:ListItem Value="04">04</asp:ListItem>
<asp:ListItem Value="05">05</asp:ListItem>
<asp:ListItem Value="06">06</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="endHour"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Minutes">
<ItemTemplate>
<asp:DropDownList id="endMinutes" runat="server" CSClass="fptextbox12">
<asp:ListItem Value="00">00</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="30">30</asp:ListItem>
<asp:ListItem Value="45">45</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="startMinutes"
ErrorMessage="*" InitialValue="Select"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AM/PM">
<ItemTemplate>
<asp:DropDownList id="endAmPm" runat="server">
<asp:ListItem Value="AM">AM</asp:ListItem>
<asp:ListItem Value="PM">PM</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="endAmPm"
ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add Another Event" OnClick="ButtonAdd_Click" />
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<FooterStyle BackColor="#AC54AA" Font-Bold="True" ForeColor="white" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#AC54AA" Font-Bold="True" ForeColor="white" />
<AlternatingRowStyle BackColor="White" />
</asp:gridview>
<br />
</div>
<asp:Button ID="btnSave" runat="server" Text="Send Request" OnClick="btnSave_Click" alt="Send Request" /><br />
<asp:Label ID="lblResult" style ="font-weight:bold; font-size:large" runat="server"></asp:Label>
<asp:Button ID="btnSave" runat="server" Text="Send Reservation Request" OnClick="btnSave_Click" alt="Send Request" /><br />
modified 7-Jul-14 12:14pm.
|
|
|
|
|
Since you now have multiple rows, you won't have an element with the ID startHour / startMinutes / etc. - they'll all have a row prefix to ensure that they get a unique ID.
Your current validation method won't actually do any validation. It will display an alert, but then allow the post to continue anyway.
Also, you probably don't want an alert for every row with an error. It would be better to keep the UI consistent by using a proper validator control. In this case, the CustomValidator control[^] is probably the best choice.
<asp:TemplateField HeaderText="End Time">
<ItemTemplate>
<asp:DropDownList id="endHour" runat="server">
...
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="endHour"
ErrorMessage="*"
SetFocusOnError="True"
/>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="endHour"
ErrorMessage="A minimum of four hours is required."
Text="*"
SetFocusOnError="True"
OnServerValidate="ValidateDuration"
ClientValidationFunction="validateDuration"
/>
</ItemTemplate>
</asp:TemplateField>
protected void ValidateDuration(object sender, ServerValidateEventArgs args)
{
Control validator = (Control)sender;
Control row = validator.NamingContainer;
int startHour = int.Parse(((DropDownList)row.FindControl("startHour")).SelectedValue);
int startMinutes = int.Parse(((DropDownList)row.FindControl("startMinutes")).SelectedValue);
string startAmPm = ((DropDownList)row.FindControl("startAmPm")).SelectedValue;
switch (startAmPm)
{
case "AM":
{
if (startHour == 12)
{
startHour = 0;
}
break;
}
case "PM":
{
if (startHour != 12)
{
startHour += 12;
}
break;
}
default:
{
args.IsValid = true;
return;
}
}
int endHour = int.Parse(((DropDownList)row.FindControl("endHour")).SelectedValue);
int endMinutes = int.Parse(((DropDownList)row.FindControl("endMinutes")).SelectedValue);
string endAmPm = ((DropDownList)row.FindControl("endAmPm")).SelectedValue;
switch (endAmPm)
{
case "AM":
{
if (endHour == 12)
{
endHour = 0;
}
break;
}
case "PM":
{
if (endHour != 12)
{
endHour += 12;
}
break;
}
default:
{
args.IsValid = true;
return;
}
}
int hourDiff = endHour - startHour;
if (endMinutes < startMinutes)
{
hourDiff--;
}
args.IsValid = hourDiff >= 4;
}
function validateDuration(sender, args){
var row = $(sender).closest("tr");
var startHour = parseInt(row.find("select[name$=startHour]").val(), 10);
var startMinutes = parseInt(row.find("select[name$=startMinutes]").val(), 10);
var startAmPm = row.find("select[name$=startAmPm]").val();
switch (startAmPm) {
case "AM": {
if (startHour === 12) {
startHour = 0;
}
break;
}
case "PM": {
if (startHour !== 12) {
startHour += 12;
}
break;
}
default: {
args.IsValid = true;
return;
}
}
var endHour = parseInt(row.find("select[name$=endHour]").val(), 10);
var endMinutes = parseInt(row.find("select[name$=endMinutes]").val(), 10);
var endAmPm = row.find("select[name$=endAmPm]").val();
switch (endAmPm) {
case "AM": {
if (endHour === 12) {
endHour = 0;
}
break;
}
case "PM": {
if (endHour !== 12) {
endHour += 12;
}
break;
}
default: {
args.IsValid = true;
return;
}
}
int hourDiff = endHour - startHour;
if (endMinutes < startMinutes) {
hourDiff--;
}
args.IsValid = hourDiff >= 4;
}
NB: Your original validation function would consider 1:45 PM to 2:00 PM as one hour. This version will take the minutes into account as well. If that's not what you want, then you can remove the entire if (endMinutes < startMinutes) { ... } block, and the code which retrieves the startMinutes and endMinutes values.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
WOW, Thank you so much Richard!
You gave me so much and I am truly grateful for your generosity.
I have a couple of questions I am afraid to ask but have no choice anyway.
The js that checks for minimum hours needed is giving me the following error:
Error: Object doesn't support property or method 'parseInt'
I believe that is a Javascript.
Thank you, thank again.
|
|
|
|
|
Whoops! Looks like Number.parseInt [^] only works in Firefox. Try using just parseInt [^] instead, without the Number. prefix.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The error is gone but the validation is not working. I tried both IE and FF.
When I say not working, it just doesn't do anything.
Rather, bypasses the validation and submits to the db anyway.
|
|
|
|
|
Do you have both the server and client-side validation in place?
Are you getting any script errors from the client-side validation?
And how are you posting to the database?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|