|
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
|
|
|
|
|
Yes, I have both server and client scripts in place.
I had to convert the server code to vb.net since that's what the rest of code is written in.
No errors from the Javascript.
I have a btnSave_Click sub. My thinking ( and I could be wrong) is that when user clicks the btnSave_Click to submit to the database but if minimum hour is not up to 4 hours, then the error is raised from your code.
Hope that's the way it should be done.
Thanks sir for your continued assistance and patience.
UPDATE: Now that I think about it, I *THINK* I know what the problem is.
Before your code, the validation included date:
var theDate = $("table[id*=Gridview1] input[id*=txtdate]").val();
var timeStart = new Date(theDate + ' ' + sHour + ':' + sMinutes + ' ' + sAmPm).getHours();
var timeEnd = new Date(theDate + ' ' + eHour + ':' + eMinutes + ' ' + eAmPm).getHours();
And also based on button click:
$('#btnSave').on('click', function () {
I am not sure how to reconcile these with your nice code Richard.
modified 7-Jul-14 11:12am.
|
|
|
|
|
OK, there were a few typos in my post, which should now be corrected:
- Missing "f" from
hourDiff within the if (endMinutes < startMinutes) block; - Missing
break statements from the switch clauses; - jQuery selectors should be
select[name$=...] instead of select[id$=...] due to changes in ASP.NET 4.0 ID generation;
I've updated my post with the Javascript code which should now work. The VB.NET code should look something like this:
Protected Sub ValidateDuration(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
Dim validator As Control = DirectCast(sender, Control)
Dim row As Control = validator.NamingContainer
Dim startHour As Integer = Integer.Parse(DirectCast(row.FindControl("startHour"), DropDownList).SelectedValue)
Dim startMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("startMinutes"), DropDownList).SelectedValue)
Dim startAmPm As String = DirectCast(row.FindControl("startAmPm"), DropDownList).SelectedValue
Select Case startAmPm
Case "AM"
If startHour = 12 Then
startHour = 0
End If
Case "PM"
If startHour <> 12 Then
startHour += 12
End If
Case Else
args.IsValid = True
Return
End Select
Dim endHour As Integer = Integer.Parse(DirectCast(row.FindControl("endHour"), DropDownList).SelectedValue)
Dim endMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("endMinutes"), DropDownList).SelectedValue)
Dim endAmPm As String = DirectCast(row.FindControl("endAmPm"), DropDownList).SelectedValue
Select Case endAmPm
Case "AM"
If endHour = 12 Then
endHour = 0
End If
Case "PM"
If endHour <> 12 Then
endHour += 12
End If
Case Else
args.IsValid = True
Return
End Select
Dim hourDiff As Integer = endHour - startHour
If endMinutes < startMinutes Then
hourDiff -= 1
End If
args.IsValid = hourDiff >= 4
End Sub
The validator won't raise an error. Instead, as with any other validator control, the Page.IsValid property will return False . So your update method should look something like:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
If Page.IsValid Then
End If
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Simply elegant Richard!
I now completely understand exactly what you did.
If minimum hour is less than 4, then the red asterick (*) is displayed.
It is working beautiful!
You have bailed me out again. Thank you soooo much, Richard.
I have got to figure out again, once more how to give you credit for the great work and then treat this thread as solved.
|
|
|
|
|
Read here to understand how element id created inside an ASP.NET template...
Understanding ASP.NET Templates[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
does anyone know how to check whether someone is a fan of a facebook page.
|
|
|
|
|
|
you can do like this after having the user permission
var user_id = 'USERID'
var page_id = 'YOUR PAGE ID';
var fql_query = 'SELECT uid FROM page_fan WHERE page_id = ' + page_id + ' and uid='+ user_id;
var query = FB.Data.query(fql_query);
query.wait(function (rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
//IS A FAN OF THE PAGE
} else {
//NOT A FAN OF THE PAGE
}
});
|
|
|
|
|
<!DOCTYPE html>
<html>
<head>
<script src="//maps.googleapis.com/maps/api/js?sensor=false"type="text/javascript"></script>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<style type="text/css">
html, body, #map-canvas {
height: 100%;
margin: 0;
}
</style>
<script type="text/javascript">
= "select * from gps ORDER BY id DESC LIMIT 1"= mysql_query($sqlgps)= mysql_fetch_array($result);
?
var map; // add map make
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(, ),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
//load();
}
function make(){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(, ), // auto refresh marker fram database mysql
//position: map.getCenter(),
draggable:true, // make move click
animation:google.maps.Animation.DROP,
map: map,
title: "Welcome to Thailand",
//icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
});
//
}
google.maps.event.addDomListener(window, 'load', initialize);
window.onload = make;
</script>
</head>
<body ">
<div id="map-canvas"></div>
</body>
</html>
|
|
|
|
|
I want to know what is the main purpose of the angular js can u axplain with any live example in asp.net
thanx
|
|
|
|
|