Jump to content

funbinod

Members
  • Content Count

    499
  • Joined

  • Last visited

Posts posted by funbinod


  1. I've a query that gets some rows with some results. and I want to sum all the results

     

    like I get $balance from a query

    while ($r = $q->fetch_array) {    echo $balance.'<br />';}

    and when I get the rows with $balance, I want to sum all of them and display at the bottom

    I tried,

    $total = 0;while ($r = $q->fetch_array) {    $total = $balance++;    echo $balance.'<br /';}echo $total;

    but its not giving the required result. please guide.

     

    thanks in advance....


  2. I want to know how can I set timezone for MySQL from phpmyadmin?

    I tried

    set time_zone = 'Asia/Kathmandu';

    and it said unknown timezone. I checked the supported timezone list, and it contains my timezone.

     

    then I tried

    set time_zone = '+5:45';

    and it succeeded. but when a row is updated, the timestamp column is not storing the correct time according to my timezone. please guide what is the problem???

     

    thankz in advance....


  3. oh thank u.

    now I changed the id for both options to 1 and 2 and now I changed the jquery selector by its name...

    	$('#dname').keypress(function(e) {		if (e.which === 13) {		    	if ($('input[name=by]').val()=='CHQ') {				$('#cqd').select();			} else if ($('input[name=by]').val()=='CASH') {				$('#ref').select();			}		}	});

    selecting by its name also not doing the proper job :( . what do u suggest me to make this done...????


  4. BY: <input type="radio" name='by' id='by' value="CASH" checked />CASH | <input type="radio" name='by' id='by' value="CHQ" />CHEQUE

    sorry! I might have been misunderstood...

     

    please guide how can I have options for radio buttons for one question???


  5. I've some problem executing some line with different condition on radio button selection...

    	$('#dname').keypress(function(e) {		if (e.which === 13) {	    		if ($('#by').val()=='CASH') {				$('#cqd').select();			} else if ($('#by').val()=='CHQ') {				$('#ref').select();			}		}	});

    in this code #by is radio button with two options - val='CASH' & val='CHQ'. on 'keypress', if CASH is selected '#cqd' should be selected and if CHQ is selected '#ref' should be selected. but this only the #cqd is selected in both conditions. please guide me to execute it properly.

     

    thanks in advance...

     


  6. max-width not working on the following.

    <table style="padding:0; border:none; border-spacing:0; max-width:98%; min-width:1000px; margin-left:auto; margin-right:auto;">

    the table width is fixed on min-width though the screen resolution or width is more than that. shouldn't it be set on max-width if the page width is more than min-width????


  7. ok

    I've done this

    	$('#name').keyup(function(e) {		getAid();        // this is the function for ajax request		$('#address').attr('disabled', 'disabled');		if (e.which === 13) {			if( ($('#aid').val() !== '')) {				e.preventDefault();				$('#address').removeAttr('disabled');				$('#address').focus();			} else {                                alert('Error!');				$('#name').select();			}		}        });

    please guide me where I've done mistake. everything seems to be working fine but the focus goes to #address whether the ajax is successful or not...


  8. hi guys! greetings!

     

    I've used ajax to get some data after user inputs some information on a <input> and hits enter.

    function getAid(){var XMLHttpRequestObject = false;if (window.XMLHttpRequest) {	XMLHttpRequestObject = new XMLHttpRequest();} else if (window.ActiveXObject) {	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");}XMLHttpRequestObject.onreadystatechange = function(){	if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {		document.getElementById('aid').value = XMLHttpRequestObject.responseText;	}}var name = encodeURIComponent(document.getElementById('name').value);XMLHttpRequestObject.open('POST', 'ajax/aid.php');XMLHttpRequestObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");XMLHttpRequestObject.send("name=" + name);}

    this function is set onBlur() method on #name field. its working fine. but I wish something more. I wish that the cursor should move to another field only after the successful ajax callback, or say only after getting data on #aid field.

     

    for example

     

    <input id="name">

    <input id="address">

    <input id="aid">

     

    when user inputs 'name' and hits 'enter', value is derived from ajax request to 'aid' field and after getting the value, the 'address' field with get the focus..

     

    please guide through...

     

    thanks in advance....


  9. hey guys!

    how can I always round up a number in php?

     

    I learnt about ROUND_HALF_UP, ROUND_HALF_DOWN, and others. but what can I do if I want to round a number always up whether it is greater than half or less than.

     

    for example

     

    12345.01 = 12346

    12345.99 = 12346

     

    please guide me.

     

    thanks in advance....


  10. hey guys! I diagnosed that the all problem is about jquery support for ".click()" and ".on()" event handlers. I am using jquery-2.1.0. but its not supporting these events. then I migrated it to 1.2.1 and used ".live()" event and everything worked. please suggest me which event is used for this on jquery-2.1.0???


  11. not working :( :( :( :'(

    	$('#sendmail').submit(function(e) {		event.preventDefault();		$("#sendmail").validate();	    	if ($("#sendmail").valid()) {        		$.ajax({		            	type: "POST",			        url: "sendmail.php",    	        		cache: false,	    	        	contentType: "application/json; charset=utf-8",	    		        data: {					msg: $('#msg').val(),					subj: $('#sub').val(),					emaill: $('#emaill').val()				},    		        	dataType: "json",	    		        complete: function(transport) {        			        if (transport.status == 200) {						alert('Mail Sent Successfully!');		                	} else {    				                alert("Please try again later!");        		        	}	            		}		        });    		}	});

  12.  

    It looks like clicking that submit button is going to submit the form and refresh the page, you're not stopping the submit.

    yes! you caught the point. it is reloading the page in stead sending ajax request (page load animated icon on the address starts running after I click send button).

     

    I tried to stop the form submit using "e.preventDefault()", "e.preventDefault()", "return false" but its not stopping the submission. is this method wrong? any other idea???


  13. Have you confirmed that the sendmail.php script works on its own?

     

    yes it does! to test it I've added some line after execution of php mail()

    if (mail($to, $subject, $body, $from)) {	$_SESSION['msg'] = 'mail sent successfully to "'.$to.'"';} else {	$_SESSION['msg'] = 'mail sent failed to "'.$to.'"';}die(header('location: notes.php'));////// this part is only to test if the script is working or not. for ajax script to execute I only use "mail($to, $subject, $body, $from)" ///////

     

    Are you saying you're not seeing an alert no matter what the response? Or you see a response but no email?

    yes! there is no any alert on any response status. neither any email...

            	        if (transport.status == 200) {				alert("Mail Sent Successfully!");                	} else {	    	                alert("Please try again later!");        	        }////////////// no response / no email ////////////////

    the php script (sendmail.php) is working very nicely, I think. if I remove the ajax part and use action='sendmail.php' in mail form, it sends mail and returns the session var.


  14. I was trying something idiot.

     

    I created 4 divs and arranged them to look like some object. and I wish them to slide away to right at once so that it looks like the displayed object moved..

     

    the effect is make on click event.

     

    I tried sliding wrapping div but it slid only first div and others disappeared. then i tried moving individual divs also. but it moved individually not at once as one object...

     

    please refer to this jsfiddle

    http://jsfiddle.net/zuv455oh/3/

    and guide me to better solution...

     

    thank u in advance...


  15.  

    You can also use your developer tools to look at the network tab to see the ajax request go out and make sure that it's working, you can use that also to look at the response from PHP.

     

    the status is ok at developer tool. it says "Status - 200 OK"

    there I found one mistake (additional extra closing curly brace). I fixed it. but still no response.

     

    one additional point--

    I am trying to send mail from a appended div after clicking the email address... following is the complete code...

    	$('#send').click(function(e) {	    $("#sendmail").validate();    	    if ($("#sendmail").valid()) {        	$.ajax({            	    type: "POST",	            url: "sendmail.php",    	            cache: false,    	            contentType: "application/json; charset=utf-8",    	            data: {			msg: $('#msg').val(),			subj: $('#sub').val(),			emaill: $('#emaill').val()		    },    	            dataType: "json",    	            complete: function(transport) {        	        if (transport.status == 200) {				alert('Mail Sent Successfully!');                	} else {    	                	alert("Please try again later!");        	        }            	    }	        });    	    }	});

    this is the appended div that contains the mail form.....

    <div id='pop'><div id='popin'><br /><form id='sendmail' name='sendmail' method='POST' action=''><input id='emaill' name='emaill' type=text value='<?php echo $aemail; ?>' /><br /><br /><textarea cols='20' rows='2' id='sub' name='sub'></textarea><br /><br /><textarea cols='20' rows='10' id='msg' name='msg'></textarea><br /><br /><input type='submit' id='send' name='send' value=SEND /> <input type='button' id='close' value='CLOSE' /></form></div></div>

  16. thank u

    now the script became

            $.ajax({            	type: "POST",	        url: "sendmail.php",    	        cache: false,    	        contentType: "application/json; charset=utf-8",    	        data: {                    msg: $('#msg').val(),                    subj: $('#sub').val(),                    emaill: $('#emaill').val()		}    	        dataType: "json",    	        complete: function(transport) {        	    if (transport.status == 200) {                        alert('Mail Sent Successfully!');               	    } else {    	                alert("Please try again later!");        	    }            	}	});

    is everything correct!!????

     

    but even its not working...


  17. i'm trying to make a mail form using ajax. but getting some problem. please guide

    following is what I tried...

     

    html

    <form id='sendmail' method='POST' action='sendmail.php'>    <input id='emaill' name='emaill' type=text value='<?php echo $aemail; ?>' /><br /><br />    <textarea cols='20' rows='10' id='msg' name='msg'></textarea><br /><br />    <input type=submit id='send' value=SEND /></form>

    jquery

    	$('#send').live('click', function() {	    $("#sendmail").validate();    	    if ($("#sendmail").valid()) {        	$.ajax({            	type: "POST",	        url: "sendmail.php",    	        cache: false,    	        contentType: "application/json; charset=utf-8",    	        data: "{ 'body': '" + $("#msg").val() + "'," + "'from': '" + $("#emaill").val() + "'," + "'subject: 'email from Mimosa Cashier Management'" + "}",    	        dataType: "json",    	        complete: function(transport) {        	    if (transport.status == 200) {                        alert('Mail Sent Successfully!');			$("#pop").hide("slide", {easing:"easeOutElastic"},1000);                    } else {    	                alert("Please try again later!");        	    }            	}	        });    	    }    	    return false;	});

    sendmal.php

    $to = $_POST['emaill'];$from = 'Mimosa Cashier Management';$msg = $_POST['msg'];mail($to,$from,$msg);

    it works if I don't use ajax. and when I use ajax it gives success message also (the success function executes). but the mail is not sent..

     

    please guide where in the code I did mistake???

     

    thanks in advance....

×
×
  • Create New...