Re: Ajax
| From: | Karl DeSaulniers | Date: | Thu, 21 Feb 2013 07:34:48 +0000 |
| Subject: | Re: Ajax | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48692@lists.php.net to get a copy of this message | ||
Hi Ethan,
With all due respect, I really wish I could help, but your structure of how your doing your
html and php and javascript mix doesn't make sense enough for me
to understand what it is your doing or how to help you. I copied and pasted your original code
in my editor and it broke all over the place with the syntax highlighting I have.
That is a big sign your code is not developed properly. Not even the basic HTML.
I'd suggest getting yourself aquatinted with basic HTML structure first,
then continue with any front or back end languages like
learn how to get the value of fields vs. a TD and how to pass them to functions.
How to echo php vars into javascript vars, etc.
Got to learn to crawl before you can walk as they say.
:)
GL,
Karl
On Feb 20, 2013, at 11:56 PM, Ethan Rosenberg, PhD wrote:
On 02/20/2013 11:40 PM, Karl DeSaulniers wrote:Karl DeSaulniers Design Drumm http://designdrumm.comOn Feb 20, 2013, at 10:13 PM, Ethan Rosenberg, PhD wrote:Karl - $k = i+1; //sets the loop to end at 11, where this ($i=0; $i<10; $i++) ends at 10 get out of bounds message.On 02/20/2013 10:49 PM, Karl DeSaulniers wrote:FYI this is redundent. for($i=0; $i<10; $i++) {I think you need to set it here. <script type="text/javascript"> $(document).ready(function(){============= Karl -$("#e1").dblclick(function(e) { var id = $(this).attr('id'); ///This was missing $.post("testClickcallback.php", {"custnum":cusn}, function getCustNo(id) { cno = 'cust'+id; cnm = "name"+id; cname = document.getElementById(cnm).innerHTML; cnum = document.getElementById(cno).innerHTML; alert("For customer "+cname+" the number is "+cnum); return; } // alert("subval");//alert(subval); ,"html"); }); }); </script> Best, Karl<snip>var id = $(this).attr('id'); ///This was missing alert(id); // alert= undefinedEthan$k = $i ; //this is not needed. $results .= "<tr><td id='name$i' >$names[$k] </td><td id='nums$k'>$nums[$k]</td></tr>";} You can just do. for($i=0; $i<10; $i++) {$results .= "<tr><td id='name$i' >$names[$i] </td><td id='nums$i'>$nums[$i]</td></tr>";} unless you need $k = $i +1; on the javascript, I think the id is equaling 0 thats why $('#e1') is not working. change to $('#e0') just for giggles. or try the &k = $i + 1 HTH, Karl DeSaulniers Design Drumm http://designdrumm.comvar id = $(this).attr('id'); ///This was missing alert(id); // alert= undefinedstill the same. Something tells me that I am accessing/setting the id incorrectly, but I can't figure out where. Or maybe something else??? Ethan