.click on row works with php table - does not work with javascript table.

Howdy,
I've run into a very interesting problem today, and I hope you'll be able to help me.
I have a page in which the top is php to read a table from the server, and post the table as the html page is being built.
The data come up as a table, and each row is clickable, that click moving the user to a different page, based on the row clicked.
Here are the relevant parts of the php code:
<?php
echo "<table id='patienttable' cellpadding=5px border=0 font-size=16px>";
echo "<tr><th width='30'>"."ID#"."</th><th width='100'>"."Last Name"."</th><th width='100'>"."First Name"."</th><th width='100'>".
"Middle Name"."</th><th width='80'>"."DOB"."</th><th width='50'>"."Zip"."</th><th width='50'>"."Gender"."</th><th width='100'>".
"Phone"."</th></tr>";
while ($row = mysqli_fetch_array($result))
blah blah blah
echo "<tr><td id='localid'>".$localid. "</td><td>".$lastname. "</td><td>".$firstname. "</td><td>".$middlename."</td><td>".$dob."</td><td>".$physzip. "</td><td>".$gender."</td><td>".$phone1.       "</td></tr>";
  echo "</table>";
?>
And here is the code to click on a row:
$("#patienttable tr").click(function() {
       var passthis = $(this).find("#localid").html();
       $.post("php/setsessionvariable.php",
              {sessionval: passthis},
     function(e) {window.location.href = "root.php"}
EVERYTHING works great - no problems - working now for about 2 months.
Today I started to build something similar, BUT! I cannot read from the database at the top of the page, I must do an ajax query, call the db, and post the data in a table;
Here is the boring, fairly straight-forward javascript code:
$.ajax({
    type: "POST",
    url: "findpatientbackend.php",
    data: {letterslastname: lastname},
    dataType : 'json',
    success: function(result) {
  $("#div1").html("");
        if(result.length >= 1)
   {var output = "";
         $("div1").html("<table id='findtable'>");
          $.each(result, function(index, value) {
                                                 output += "<tr><td width='100px'></td><td id='localid' width='100px'>"
             + value.localid + "</td><td width='100px'>"
             + value.lastname + "</td><td width='100px'>"
             + value.firstname + "</td><td width='100px'>"
             + value.middlename + "</td><td width='100px'>"
             + value.dob + "</td></tr>";
            $("#div1").html(output);
         $("div1").html("</table>");  
    error : function() { alert("error on return"); }
And here is the click row code, almost EXACTLY like the one above:
$("#findtable tr").click(function() {
       var passthis = $(this).find("#localid").html();
       $.post("php/setsessionvariable.php",
              {sessionval: passthis},
     function(e) {window.location.href = '../root.php'}
All the "stuff" loaded onto the page just fine, BUT, absolutely nothing happens when I click a row.
Playing around this afternoon, I did a "View Source" on both pages, and saw something VERY interesting;
1 - The table written by PHP is present, can be seen, and therefore is "clickable" to the jquery .click function.
2 - The table written by javascript is INVISIBLE! I cannot see it in the source view (but I can see it on the screen) and therefore the .click function can't see it either.
Questions:
1. How can I make the table written in javascript "clickable" - how can I make the javascript table "visible"?
2. Could it be the use of ".html" to post the table to the div? Is there another way?
And again, I thank you in advance for any help.

I found the solution to my problem, and perhaps my comments here will help others.
Thinking a bit more, I wrote a separate javascript routine that created a table, allowed it to be styled, and allowed it to be clickable.
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" type="text/javascript"></script>
<style>
#findtable {
width:200px;
background-color:#CFD3FE;
margin:10px auto;
text-align:center;}
</style>
<body>
<div id="puttablehere"></div>
<script>
$(document).ready(function () {
var output = "<table id='findtable'>";
for (var i = 0; i<15; i++) {output += "<tr><td width='100px'>X</td><td id='localid' width='100px'>X</td></tr>";}
output += "</table>";
$("#puttablehere").html(output);
$("#findtable tr").click(function(e) { alert("it works!"); });
</script>
</body>
</html>
The initial code I posted was creating the table the wrong way.
You have to create the WHOLE table at the same time, and post it all at once.
The code above does that.
My learning points are:
1. To create a table in javascript, and post it with a $("#puttablehere").html(output); call, you must put the ENTIRE table into that single string variable called "output" (or whatever you want to call it).
2. Everytime you call a jqeury .html function like this: ---("#puttablehere").html(output); -- It COMPLETELY over-writes the whole div/tr/td block that it is pointed at.
3. If you create a table in javascript (client side) you cannot see it with "View Source" - because what is posted in the table is AFTER the DOM is loaded.
Creating a table with php server side - you CAN see, because it is posted with the DOM.
So I thank you for your ideas, and I hope this may help another noob, such as myself, in the future.
Adios!

Similar Messages

  • Early Adopter release : Extract DDL for tables does not work

    Hi,
    just had a look at Raptor - really nice tool - easy install - could be a replacement for SQLnavigator for us. One or two things I noticed though ...
    1)
    Export->DDL for tables does not work throws following error
    java.lang.ClassNotFoundException: oracle.dbtools.raptor.dialogs.actions.TableDMLExport
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at oracle.ideimpl.IdeClassLoader.loadClass(IdeClassLoader.java:140)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:164)
         at oracle.dbtools.raptor.dialogs.BasicObjectModifier.launch(BasicObjectModifier.java:142)
         at oracle.dbtools.raptor.dialogs.BasicObjectModifier.handleEvent(BasicObjectModifier.java:210)
         at oracle.dbtools.raptor.dialogs.actions.XMLBasedObjectAction$DefaultController.handleEvent(XMLBasedObjectAction.java:265)
         at oracle.ide.controller.IdeAction.performAction(IdeAction.java:530)
         at oracle.ide.controller.IdeAction$1.run(IdeAction.java:785)
         at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:804)
         at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:499)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
         at java.awt.Component.processMouseEvent(Component.java:5488)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
         at java.awt.Component.processEvent(Component.java:5253)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3955)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    and 2)
    when I click on a package body - I get "loading ..." below it but it never puts the
    procedure names in and the "loading ..."message stays in the tree view - however you do get to see the packages in the source window.
    Realise this is very much a work in progress and am grateful to see an early release such as this. Looking forward to the production release.
    Best regards,
    David.

    OK thanks for looking ....you've obviously got the fixes on your to do lists
    Noticed that the SQL tab when you select an object works fine - displays the
    DDL for the object
    Do you think you'll have functionality so you can select many objects (shift left click) and
    then create a DDL script for them? It looks like you can do this for all objects in a schema but
    the ability to select a subset of objects in a schema would be very useful for our DBA's.
    Couldn't see any good reason for keeping using SQLNavigator
    Many congratulations on producing such a useful tool.
    Kind regards,
    David.

  • What if sync with new computer does not work. logical connection to old with WindowsXP, 32 bit version of iTunes. New is Windows7 with 64bit version

    What if sync with new computer does not work?
    logical connection to old with WindowsXP, 32 bit version of iTunes.
    New is Windows7 with 64bit version

    Syncing to a new iTunes library or computer will erase your iPod. Only if you back up your iPod manually before syncing, you can restore your device from that backup again. A manual backup does not include the sync process.
    Do this:
    Disable autosync in iTunes, connect your iPod to your new computer and right click on it in the device list and choose backup. iTunes will backup your iPod without syncing.
    Transfer your purchases the same way, choosing "transfer purchases" this time.
    When you connect your phone for the first time, all media content will be erased. But you can restore your settings and app data from your manual backup afterwards.
    Don't forget to set up at least one contact and event on your new computer to be able to merge calendars and contacts when you sync the iPod for the first time.
    Music is one way only, from the computer to your device, unless you bought the songs in iTunes and transferred your purchases.
    There is 3rd party software out there, but not supported by Apple, see this thread: http://discussions.apple.com/thread.jspa?threadID=2013615&tstart=0
    About backups and what's saved: http://support.apple.com/kb/HT4946
    How to back up and restore:http://support.apple.com/kb/HT1414
    How to download apps for free again:http://support.apple.com/kb/HT2519
    Saving other data is also described here. How to back up your data and set up as a new device
    If your iPod can't be recognized by Windows, try these tips: iOS: Device not recognized in iTunes for Windows

  • Connecting Wahoo Blue HR with iPhone 5 does not work, tried everything possible

    Connecting Wahoo Blue HR with iPhone 5 does not work, tried everything what I could find in the interenet as solution??????

    IPhone 4s, iOS 7.1.1: iphone can't connect to wahoo HR BT4.0 sensor :((( Wverything worked fine with iOS 6 !!!

  • Hyperlink with tracking applied does not work in PDF

    We use lots of web addresses in our advertising and generally the web addresses automatically convert to hyperlinks when we distill the files and make PDFs. Recently we've had two instances where someone applied tracking or justification to the line of text containing the url to make it spread across the page. When we make our PDF the url is not clickable. Is there anyway around this? We tried actually creating a hyperlink manually in InDesign by using the Hyperlinks panel and entering the address, but that didn't work either.

    Peter,
    We'll look into that. We already do two separate PDFs for print and web, but
    we are distilling both right now. Wouldn't be too much of a problem to
    change to exporting the web version I don't think.
    I did a test, just curious, is there a way to keep it from putting a black
    box around the link on the PDF?
    Thanks for your help! We appreciate it!
    Beth
    From: Peter Spier <[email protected]>
    Reply-To: <[email protected]>
    Date: Fri, 14 May 2010 13:24:04 -0600
    To: Beth Phillips <[email protected]>
    Subject: Hyperlink with tracking applied does not work in PDF
    Distilled PDF uses Postscript which does not support hyperlinks and
    interactivity. To make your hyperlinks in ID you'll need to export and check
    the Include Hyperlinks and Include Interactiviity boxes.
    Your printer doesn't need hyperlinks because they don't work on a printed
    page. The requirements for print and interactive PDF are quite different, and
    you may find you need to make two versions.
    >

  • HT1849 when I download album works from itunes it does not associate with the correct artist

    when I download album works from itunes it does not associate with the correct artist

    Where are you looking to download them from ? You might be able to redownload them via the Purchased link under Quicklinks on the right-hand side of the iTunes store homepage on your Mac's iTunes. If that album shows there but doesn't have the cloud symbol against it for redownloading then that implies that it's still in your iTunes library

  • I own the 4s and my BT Planttronics Pro works fine with calls but does not work to listen to music? Any ideas on how to correct this?

    I own the 4s and my BT Planttronics Pro works fine with calls but does not work to listen to music?
    Any ideas on how to correct this?
    Thanks-Vitaleyes

    I don't know what they call it, but my plantronics voyager pro, and my wifes plantronics voyager pro+ will not let you hear music through the headset.  My Blueant T1 does support it and plays the music through the deadset.

  • My camera works with the photobooth and with skype but does not work with online applications such as "lolcam from facebook" or "faceonthehole" application. Please help

    My camera works with the photobooth and with skype but does not work with other applications like the "lolcam" from facebook or the " faceonthe hole" application. Can anyone help?

    There was a issue with school computers being used to spy on kids in their bedrooms, Mac's were involved.
    So Apple most likely tightened the API's to only select, trustworthy companies as not to abuse the web cam access priviledge.
    If you want to use a web cam with these other programs and services, you'll likely have to buy a third party USB one, so you can manually disconnect it.
    There isn't a way to physcially disconnect the built in web cam on Mac's without busting open the machine.

  • With IOS6 3G does not work.  This has already happened with IOS5.1, was only solved with IOS5.1.1.  More anyone have this problem? How do you solve?

    With IOS6 3G does not work.
    This has already happened with IOS5.1, was only solved with IOS5.1.1.
    More anyone have this problem? How do you solve?

    This response is a little late as I just read about your problem. I have a 2012 Dodge Charger and a 2012 Chrysler Town and Country and both worked flawlessly with the iPhone 5s my wife and I had. However, we just upgraded to the iPhone 6 and Uconnect will receive calls but you cannot answer them. You can callout successfully, however. the annoyance being the inability to answer incoming calls in the HandsFree mode.

  • In iTunes 11.1 (I26) , I cannot find how to delete podcast listings showing undownloaded podcasts. Delete does not work. Option Delete does not work.  Dragging to the trash does not work. Under Edit, Delete is greyed out. Mac OS 10.6.8

    in iTunes 11.1 (I26) , I cannot find how to delete podcast listings showing undownloaded podcasts. Delete does not work. Option Delete does not work. Dragging to the trash does not work. Under Edit, Delete is greyed out. Mac OS 10.6.8.
    Tom at the Genius Bar told me that Option Delete would work. It does not.
    I had to upgrade to iTunes 11.1.(I26) because it is required with OS7 on my iPod Touch (5th Gen). I have tried shutting down iTunes, then shutting down the entire system. This is the first in many visits that the Genius Bar gave me a solution that did not work.
    This is a big awkward computer locked to my desk. I would rather not unlock it and then carry it through a shopping center to the Genius Bar if i can avoid oit.
    When I installed iTunes 11.1, I discovered that Ihad to resubscribe to virtually all of the podcasts that I had previously been subscribed to. That was a surprise.

    Hello Achates:
    I did not read the rather long post. If you wish to reinstall OS X 10.4, use your software install DVD. Backup is essential. To minimize your risk, I would use an archive and install:
    http://docs.info.apple.com/article.html?artnum=107120
    In that way, you will have a fresh copy of OS X and your current settings will be preserved.
    Incidentally, I do not agree that the printer problem is best solved by reinstalling OS X. I have had HP printers for sometime and, on one occasion, had difficulty after an upgrade. HP technical support walked me through uninstalling all traces of the HP driver and then reinstalling.
    Barry

  • Firefox has detected the server is redirecting the request for this address in a way that will never complete. This is happening in my email program with comcast but does not happen with IE e

    Question
    firefox has detected the server is redirecting the request for this address in a way that will never complete. This is happening in my email program with comcast but does not happen with IE e edit

    Thanks to cor-el for the suggestion given in the link. Sadly I have to report:
    1) It is not a bookmark problem and it makes no difference whether I put
    www.adobe.com or 192.150.18.117 in the address bar.
    2) Cookies are allowed and there are no exceptions set
    3) All cookies have been deleted
    4) network.http.sendRefererHeader is already set to 2
    That deals with the items in the linked document.
    Additional information:
    5) I can get into the adobe site from a clean "in memory" installation of PuppyLinux using Seamonkey using the same router and dhcp setup.
    6) un-installing all Mozilla products - rebooting and re-installing makes no difference even when I remove the mozilla folder from docs&settings.
    so as I said in previous post (as annonymous) not a lot makes sense.
    Bear in mind that I have no problem running tracert in a command window
    Tracing route to www.adobe.com [192.150.18.117] over a maximum of 30 hops:
    1 11 ms 10 ms 9 ms 10.0.0.1
    2 13 ms 12 ms 11 ms glo-2-dsl.as9105.net [212.74.111.191]
    3 13 ms 12 ms 11 ms ge1-2-27.glo0.as9105.net [212.74.106.106]
    4 14 ms 12 ms 13 ms pos0-0.bri1.as9105.net [212.74.108.162]
    5 17 ms 16 ms 17 ms ge0-0-0.he-lon0.as9105.net [212.74.109.14]
    6 17 ms 17 ms 16 ms 10.72.11.75
    7 16 ms 17 ms 17 ms xe-0-3-0-10.lon20.ip4.tinet.net [213.200.77.177]
    8 91 ms 92 ms 99 ms xe-5-1-0.was12.ip4.tinet.net [89.149.184.34]
    9 92 ms 92 ms 93 ms xe-0.equinix.asbnva01.us.bb.gin.ntt.net [206.223.115.12]
    10 162 ms 170 ms 162 ms as-3.r20.snjsca04.us.bb.gin.ntt.net [129.250.2.167]
    11 166 ms 166 ms 165 ms ae-1.r07.snjsca04.us.bb.gin.ntt.net [129.250.5.53]
    12 162 ms 163 ms 161 ms xe-0-2-0-3.r07.snjsca04.us.ce.gin.ntt.net [128.241.219.86]
    13 166 ms 163 ms 161 ms 192.150.18.11
    14 166 ms 166 ms 165 ms www.adobe.com [192.150.18.117]
    Trace complete.
    and I can ping the site.
    so where now ?

  • I started the OS system from a backup hard drive. Now My Adobe products doesnt work. "the licensing does not work for this product" Error code 150:30. Help me please!!

    I started the OS system from a backup hard drive. Now My Adobe products doesnt work. "the licensing does not work for this product" Error code 150:30. Help me please!!

    Reinstall the software properly. migration/ backups do not work due to the specific requirements of the activation system.
    Mylenium

  • Select All in a table does not work for Drag and Drop

    Hi. I am using Jdeveloper 11.1.1.2 but have also reproduced in 11.1.1.3.
    I am trying to implement drag and drop rows from one table to another. Everything works fine except when I do a Select All (ctrl-A) in a table, the table visually looks like all rows are selected, but when I try to click on one of the selected rows to drag to the other table, only the row I click on is dragged.
    I tried setting Range Size -1, fetch mode to FETCH_ALL, content delivery to "immediate" but nothing works.
    I even have reproduced not using a view object but just a List of beans with only 5 or 10 beans showing in the table.
    Does anyone know how to get Select All to work for a Drag Source?
    Thanks.
    -Ed

    Frank-
    OK, thanks for looking into that. I also submitted this service request, which includes a simple sample app to demonstrate the problem:
    SR #3-2387481211: ADF Drag and Drop does not work for rows in table using Select All
    Thanks again for the reply.
    -Ed

  • Since last update anything on the first three lines of a web page if it has a a button to click on to go to another page does not work. use Google Crome for fo

    Loging onto my bank I go to the barclays pege there on the top line is "log in" it used to work when I click on it but has stoped, any button on the first three lines of a web page does not work.
    I now use Google crome but would like to stay with Firefox if this coruption can be sorted.
    Rod

    Please reload the webpage while bypassing the cache using '''one''' of the following steps:
    *Hold down the ''Shift'' key and click the ''Reload'' button with the left mouse key.
    OR
    *Press ''Ctrl'' + ''F5'' or ''Ctrl'' + ''Shift'' + ''R'' (Windows and Linux)
    *Press ''Command'' + ''Shift'' + ''R'' (Mac)
    See if this helps solve the issues you had and please report back to us!

  • Icloud log in with Apple id  does not work from my mac when i try to run on photo stream

    When I try to active photostream or sharing via icloud it does not work I get an errormessage that there is communication problems with icloud. I cant get around to administrate the stream from the Icloud site or via my imac directly. It has never worked!

    yes, the apple id works for everyting else, but not for icloud. on my phone and ipad it is set up with the correct apple id and password. however, when i try to log on to icloud under system by clicking the icon the erromessag that i get is unknown apple id or password.

  • DHCP with redundant Gateway does not work

    I am having trouble connecting to my office network using Wifi.
    I have done some investigation and found the problem which is...
    When DHCP server serves the request and replies with multiple/redundant gateways, the device does take the IP and communicates within the local network but ignores the gateway and is not able to connect the outside network.
    When I requested my Systems Administrator and he added specific setting for my device's MAC address and sent only one gateway in DHCP reply, device starts to connect outside.
    Our office has other debian based and CentOS based systems running including Ubuntu workstations but none of them is having problem with multiple/redundant gateways but only N900 is having this problem. It means that the problem is not inherited from Linux or Debian but the bug is related to Maemo itself.
    I have tried to tell add some technical details and do not expect answers like to check firewall and so. This is a genuine problem and is not intermittent. We have experienced it using MS DHCP server under windows 2003 and win 2k as well.
    End users: Please try to duplicate the problem before suggesting a work around or anything
    Developers/Admins/Officials:  I hope you acknowledge the problem soon.

    Yes it is uncommon configuration in house holds but in offices or places that have access to more than one Internet connection the configuration will be common. Houses normally have one small router with one internet connection. However in many offices the router is attached to multiple connections and manages fault-tolerance. Having said all that, regardless of how often it is used, when used it wont work and it is a bug.
    In DHCP protocol "003 Router" is defined as a list of IPs not a single IP and if DHCP protocol is properly supported this should have work. What I mean is that this problem is related to DHCP implementation. Following is the output of route command...
    ACTUAL OUTCOME:
    ===============
    / $ sudo /sbin/route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.2.15    *               255.255.255.0   U     0      0        0 wlan0
    / $
    EXPECTED OUTCOME:
    =================
    / $ sudo /sbin/route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.2.15    *               255.255.255.0   U     0      0        0 wlan0
    default         192.168.2.1     0.0.0.0         UG    0      0        0 wlan0
    default         192.168.2.2     0.0.0.0         UG    10     0        0 wlan0
    / $
    I already posted the big on Bugzilla
    https://bugs.maemo.org/show_bug.cgi?id=9662
    Well I posted this here as well so if someone else also faces the same problem (not sure if there will be one) but they should at-least know the problem instead of thinking that why the hell my internet does not work in office when there is no firewall blocking it.. :-)
    I do hope to get it viewed by a "sympathetic developer" :-)
    I currently am not into develop/modify scripts but if this is not fixed by others then I believe I don't have a choice.
    For now as I mentioned I did a work around by adding an IP reservation in my DHCP server which allows me to fix it to one Gateway for this MAC address only. But if I did not have admin access over my DHCP server, I was in trouble then and maybe would not be able to event troubleshoot and identify the problem.

Maybe you are looking for