473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

onclick display insert form

201 100+
how do i get this insert form to display for the results record id 1 once and record id 2 once instead of looping though all of foreign keys for record 1. this is in refferance to the code for sub query insert form on click.

for example: i have 10 records for record id 1 then the last record for 1 id is 10 that should show the insert form. instead of having all 10 records showing the form.

thanks in advance for your help!

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3.     function toggle_visibility(id) {
  4.        var e = document.getElementById(id);
  5.        if(e.style.display == 'block')
  6.           e.style.display = 'none';
  7.        else
  8.           e.style.display = 'block';
  9.     }
  10. //-->
  11. </script>
  12.  
  13. </head>
  14.  
  15. <body>
  16. <?php
  17. //c.sfk={$row['sfk']}
  18.  
  19. mysql_select_db($database_Del_Comments, $Del_Comments);
  20.  
  21. $result = sprintf("SELECT a.Id, a.Type, 
  22. a.Dates, 
  23. a.UIdFk as UIdFk, 
  24. b.Id as Did, 
  25. b.comment as Comment, 
  26. b.dates as Day, 
  27. b.sfk as Sfk ,
  28. aes_decrypt(e.ProfileName, '$Ukey') as Name,
  29. substr(i.Path, 4) as Path
  30. FROM 
  31. asstatusupdate as a   
  32. left join asstatusdata as b 
  33. on a.id = b.sfk 
  34. right join ASWebInfo as e
  35. on e.Uidfk = a.uidfk
  36. right join ASManyAlbums as f
  37. on f.UserId=a.uidfk
  38. right join ASAlbums as g
  39. on f.AlbumId=g.Id
  40. right join ASTitle as h
  41. on g.Id=h.AlbumId
  42. right join ASData as i
  43. on h.Id=i.TitleId
  44. where a.uidfk in (select friendid from asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
  45. ");
  46. $statusUpdate = mysql_query($result, $Del_Comments) or die(mysql_error());
  47.  
  48. $category_id = '';
  49.  
  50. echo '<table align="center" width="40%" border="3" cellpadding="0" cellspacing="0">'; 
  51. while($row = mysql_fetch_array($statusUpdate)) {
  52.     if ($row['Id'] != $category_id) {
  53.         $category_id = $row['Id'];
  54.  
  55.         // grab table variables    
  56.             $Type = $row['Type'];
  57.         $Dates = $row['Dates'];
  58.         $Comment = $row['Comment'];
  59.         $Name = $row['Name'];
  60.         $Path = $row['Path'];
  61.         $FriendId = $row['UIdFk'];
  62.         $SFK = $row['Sfk'];
  63.  
  64.         echo '<tr>';
  65.         echo '    <td align="center">', $Name, '<br><a href="source/source.php?FriendId=',$FriendId,'"><img src="',$Path,'" height="120" width="120" align="middle" border="3" /></a></td>';
  66.         echo '    <td align="center"> ',$Dates,'<br><br>',$Type,'<br/>',$Comment,'</td>'; 
  67.         echo '    <td>',$category_id,'</td>';
  68.         echo '    <td>',$SFK,'</td>';
  69.         echo '</tr>';
  70.     } // end of if
  71.  
  72. mysql_select_db($database_Del_Comments, $Del_Comments);
  73.     $comments= sprintf("SELECT 
  74.           c.sfk as sfk1,
  75.           c.UIdFk0,
  76.           d.Memo as Memo,
  77.           d.Date as Dates1,
  78.           e.ProfileName,
  79.           substr(i.Path, 4) as Path
  80.      FROM 
  81.      asmanystatusupdate as c
  82.      left join ascomments as d     on d.id = c.cfk
  83.      right join ASWebInfo as e     on e.Uidfk = c.uidfk0
  84.      right join ASManyAlbums as f     on f.UserId=c.uidfk0
  85.      right join ASAlbums as g     on f.AlbumId=g.Id
  86.      right join ASTitle as h     on g.Id=h.AlbumId
  87.      right join ASData as i     on h.Id=i.TitleId
  88.      where c.sfk={$row['Sfk']} AND c.uidfk0 in (select friendid from asfriends where uidfk0='1') and i.DefaultProfilePic='Y'  order by dates desc;
  89.      ");
  90. $statusComments = mysql_query($comments, $Del_Comments) or die(mysql_error());
  91.     while($user_row = mysql_fetch_array($statusComments)){
  92.         // test the query
  93.         //if($row['sfk'] == $user_row['sfk']) 
  94.         {
  95.  
  96.             $Dates1 = $user_row['Dates1'];
  97.             $Memo = $user_row['Memo'];
  98.             $Name1 = $user_row['Name'];
  99.             $Path1 = $user_row['Path'];
  100.             $FriendId1 = $user_row['UIdFk0'];
  101.             $SFK1 = $user_row['sfk1'];
  102.  
  103.             //row and cell for "outer" while        
  104.              echo '<tr>';
  105.              echo '<td colspan="4" style="padding-left:1em;">';
  106.                 // display table
  107.                 echo '<a href="#0'."$SFK1".'" onclick="toggle_visibility(\'foo1'."$SFK1".'\');" ;return false\" style=\"position:relative\">Click here to show records</a>'; // to show comment records
  108.                   echo '<div id="foo1'."$SFK1".'"style="position:relative;display:none">'; // to show comment records
  109.                 echo '<table align="center" width="60%" border="3" cellpadding="0" cellspacing="0">'; 
  110.                 echo '<tr>';
  111.                 echo '    <td align="center">',$Name1,'<br/><a href="source/source.php?FriendId=',$FriendId1,'"><img src="',$Path1,'" height="120" width="120" align="middle" border="3" /></a></td>';
  112.                 echo '    <td align="center" width="40%"> ',$Dates1,'<br/><br/><br/>',$Memo,'</td>';
  113.                 echo '    <td>' ,$category_id, '</td>'; 
  114.                 echo '    <td>',$SFK1,'</td>';
  115.                 echo '</tr>';
  116.                 echo '</table>';
  117.                 echo '</div>';  // for comment results show query
  118.             //end row and cell for outer while
  119.              //echo '</td>';
  120.              //echo '</tr>';
  121.  
  122.   echo '<form action="$editFormAction" method="post" name="form1" id="form1">';
  123.   echo '<a href="#'."$SFK1".'" onclick="toggle_visibility(\'foo'."$SFK1".'\');" ;return false\" style=\"position:relative\">Click here to toggle visibility of element #foo</a>';
  124.   echo '<div id="foo'."$SFK1".'"style="position:relative;display:none">';echo '<table align="center">';
  125.     echo '<tr valign="baseline">';
  126.       echo '<td nowrap="nowrap" align="right">Memo:</td>';
  127.       echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
  128.     echo '</tr>';
  129.     echo '<tr valign="baseline">';
  130.       echo '<td nowrap="nowrap" align="right">&nbsp;</td>';
  131.      echo ' <td nowrap="nowrap" align="right">&nbsp;</td>';
  132.    echo ' </tr>';
  133.     echo '<tr valign="baseline">';
  134.      echo ' <td nowrap="nowrap" align="right">&nbsp;SFK:' ."$SFK1". '</td>';
  135.      echo ' <td><input type="submit" value="Insert record" /></td>';
  136.    echo ' </tr>';
  137.  echo ' </table>';
  138.   echo '<input type="hidden" name="Id" value="" />';
  139.   echo '<input type="hidden" name="Id" value="" />';
  140.  echo ' <input type="hidden" name="SFk" value="' ."$SFK1". '" />';
  141.  echo ' <input type="hidden" name="MM_insert" value="form1" />';
  142.  echo '</form>';
  143. echo '</div>';
  144.         } // end of if
  145.  
  146.     } // end of while loop
  147. }// end of main loop
  148. echo '</table>';
  149. ?>
  150.  
Attached Files
File Type: zip Untitled Document.pdf.zip (1.99 MB, 120 views)
May 17 '11 #1
1 2215
just make form in one <div> . give id for this <div> with style= display:none;

after make event onclick make code ;;

document.getElementByid("div_id").style.display="b lock";
May 17 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nick | last post by:
Hi, I am tring to display a form that does not show in either the task bar or when the user alt-tabs. The form is running full screen and is set to have no border. Nick
1
by: Mr Utkal Ranjan Pradhan | last post by:
Hi Friends I want to develop a windows service application, which will open a port on the machine and constantly it will listen from that port. And when any data comes to that port I want to...
2
by: Bernie Yaeger | last post by:
I have developed a .dll to display a form that controls a simple routine. Oddly, you can't use messagebox.show unless you do one of two things: either use an imports system.windows.forms or...
3
by: Brett Romero | last post by:
My application start like this: frmMaster MainForm = new frmMaster(); System.Windows.Forms.Application.Run(MainForm); The flow is that MainForm shows then a SecondForm shows after the user...
0
by: yasker | last post by:
Hi, I got a problem in display a sub form. My app contains two form: main and sub. I want sub form display before main form, to provide some information to it. I use a NotifyIcon to activity...
5
by: Paul | last post by:
Is it possible to display a form inside another form? What component should I use?
4
ak1dnar
by: ak1dnar | last post by:
I need to display a form dynamically. First i load the page and at that time Login button will display. Nothing else. If some clicks the Login button, then only I want to display the Form. So...
1
by: Zaher Rabah | last post by:
How can I display a form in dialog mode by press any keys in the keybaord in access 2003. This form is used as calculater "For fast calculate" This is the idea.
1
by: menyki | last post by:
am designing a software. in the software i want the splash to display for sometime, say 1 minute then it will close and the main form will come up. i included timer control in the splash form i...
8
mandrekar salim
by: mandrekar salim | last post by:
hi guys , i'm using visual studio 2005. now i've to create a insert form which shud be connected to database(mssql). can any one tell me how to do dat. as i'm new to visual studio i dnt knw it.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.