10 Replies Latest reply on Apr 20, 2009 12:41 PM by Albert S.

    Can I have 2 on clicks in one form?

      What I am doing is:

       

      User can click the following button, a popUp javascript function (pUp)  will be called.  This works OK.

       

      I also want to keep track the hit rate for the link.  I have the click.php which will write a record to a table.

       

      I don't know how to put the above 2 functions together on a single click.

       

      Please help.

      Patty

       

       

      <form id="form1"   name="form1" method="post" target="_top"   action="">
          <input name="t1" type="hidden" value="<?php echo $row_news['cdetail'] ; ?>"  />
          <input name="t2" type="hidden" value="<?php echo $row_news['clink'] ; ?>"  />
          <input name="t4" type="hidden" value="<?php echo $row_news['aid'] ; ?>" />
          <input name="t5" type="hidden" value="true" />
          <input name="t3" id="t3"  class="indexT24" type="button" checked="checked" value="<?php echo $i . ")  " . $row_news['cname']; ?>"  onmouseover="this.className='indexT25'" onmouseout="this.className='indexT26'" onclick="pUp(t1.value,t2.value,t5.value)"  />
         </form>

        • 1. Re: Can I have 2 on clicks in one form?
          Albert S. Level 3

          Hi Patti,

           

          Is the code in click.php a function?

          • 2. Re: Can I have 2 on clicks in one form?
            Level 1

            Hi Albert,

            No, the code in click.php is not a function.  It just will update a record ( to record the click rate information). 

             

            I've just want to record the hit rate when user hit the button.

             

            When the user hit the button, I want it to do 2 things:

            1) pop Up window (function "pUp"  is written using Javascript)

            2) run click.php which will update the hit rate.

             

            Hope you can give me some hints.

             

            Thanks in advance.

            Patty

            • 3. Re: Can I have 2 on clicks in one form?
              Albert S. Level 3

              Hi Patti,

               

              It's been a crazy week for me. Anyway. Off the top of my head before testing anything I was thinking is convert your click.php to a function then you can call the function from the one onclick in the form. onclick="pUp(t1.value,t2.value,t5.value);trackclick()"

               

              Does your click.php contain a lot of code?

              • 4. Re: Can I have 2 on clicks in one form?
                Albert S. Level 3

                Or does your click.php do something like click.php?url=http://something.com

                so as its redirecting its tracking the click?

                • 5. Re: Can I have 2 on clicks in one form?
                  Albert S. Level 3

                  Not sure if something like this would work for you.

                   

                  Adding the onsubmit to your form.

                   

                  <form id="form1"   name="form1" method="post" target="_top"   action="" onsubmit="click.php">
                      <input name="t1" type="hidden" value="<?php echo $row_news['cdetail'] ; ?>"  />
                      <input name="t2" type="hidden" value="<?php echo $row_news['clink'] ; ?>"  />
                      <input name="t4" type="hidden" value="<?php echo $row_news['aid'] ; ?>" />
                      <input name="t5" type="hidden" value="true" />
                      <input name="t3" id="t3"  class="indexT24" type="button" checked="checked" value="<?php echo $i . ")  " . $row_news['cname']; ?>"  onmouseover="this.className='indexT25'" onmouseout="this.className='indexT26'" onclick="pUp(t1.value,t2.value,t5.value)"  />
                     </form>

                  • 6. Re: Can I have 2 on clicks in one form?
                    Level 1

                    form   action="" method="post"   name="form1" target="_top" id="form1"  onsubmit="click.php" >
                        <input name="t1" type="hidden" value="<?php echo $row_news['cdetail'] ; ?>"  />
                        <input name="t2" type="hidden" value="<?php echo $row_news['clink'] ; ?>"  />
                        <input name="t4" type="hidden" value="<?php echo $row_news['aid'] ; ?>" />
                        <input name="t5" type="hidden" value="true" />
                        <input name="t3" id="t3"  class="indexT24" type="button" checked="checked" value="<?php  $aid=$row_news['aid'] ; echo $i . ")  " . $row_news['cname']; ?>"  onmouseover="this.className='indexT25'" onmouseout="this.className='indexT26'" onclick="pUp(t1.value,t2.value,t5.value)"/>   
                        </form>

                     

                    CLICK.php

                    <?php
                    mysql_select_db($database_abb, $abb);
                    $query_Recordset1 = "SELECT * FROM clickrcd";
                    $Recordset1 = mysql_query($query_Recordset1, $abb) or die(mysql_error());
                    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
                    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

                     

                    $aid=22;
                    echo " aid ..........." . $aid;
                    $user_ip = $_SERVER['REMOTE_ADDR'];
                    $user_agent = $_SERVER['HTTP_USER_AGENT'];
                    $now=date('Y-m-d H:i:s');
                    $id1=$_COOKIE[PHPSESSID];
                    $query_result4="INSERT into clickrcd (`caid`, `ses_id` , `start_time` , `last_time`,`user_ip`, `lang`) value ('$aid', '$id1','$now', NULL,'$user_ip','en')";
                    $result4 = mysql_query($query_result4, $abb) or die(mysql_error());

                    mysql_free_result($Recordset1);
                    ?>

                    Hi Albert,

                    I put click.php onsubmit but it seems do nothing.

                     

                    When the user hit the button, I want it to do 2 things simultaneously:

                    1) pop Up window (function "pUp"  is written using Javascript)

                    2) run click.php which will update the hit rate.

                     

                    thanks

                    Patty

                    • 7. Re: Can I have 2 on clicks in one form?
                      Albert S. Level 3

                      Hi Patti,

                       

                      Try converting it to a function. Include the function to the page or just place above the above the HTML

                      <?php

                      function trackClick() {
                      include("Connections/abb.php"); // This will need to be the connections file to the db. I am just guessing at the name and location.
                      mysql_select_db($database_abb, $abb);
                      $query_Recordset1 = "SELECT * FROM clickrcd";
                      $Recordset1 = mysql_query($query_Recordset1, $abb) or die(mysql_error());
                      $row_Recordset1 = mysql_fetch_assoc($Recordset1);
                      $totalRows_Recordset1 = mysql_num_rows($Recordset1);

                       

                      $aid=$row_Recordset1['aid'];
                      $user_ip = $_SERVER['REMOTE_ADDR'];
                      $user_agent = $_SERVER['HTTP_USER_AGENT'];
                      $now=date('Y-m-d H:i:s');
                      $id1=$_COOKIE[PHPSESSID];
                      $query_result4="INSERT into clickrcd (`caid`, `ses_id` , `start_time` , `last_time`,`user_ip`, `lang`) value ('$aid', '$id1','$now', NULL,'$user_ip','en')";
                      $result4 = mysql_query($query_result4, $abb) or die(mysql_error());

                       

                      mysql_free_result($Recordset1);
                      }

                      ?>

                      Then call it from the onclick

                      onclick="pUp(t1.value,t2.value,t5.value);trackClick()"

                      • 8. Re: Can I have 2 on clicks in one form?
                        Albert S. Level 3

                        Hi Patti,

                         

                        Things finally calmed down a little at work for me. How's the function going?

                        • 9. Re: Can I have 2 on clicks in one form?
                          Level 1

                          Hi Albert,

                          Sorry I am a bit late to get back to you.  I have problem to locate the reply button by visiting the message page.

                           

                          Anyway, I stopped on this topic. 

                           

                          Now, I am working on CSS problems instead.

                           

                          I wonder can you give me a hand again.

                           

                          My problem is : 

                          I created my css base on IE7.  Now I want to check on other browsers, e.g. ie6, ie 5, firefox ...etc. everything mess up.

                           

                          I found some example but it did not work.  I wonder can you give me some hints.

                           

                          Code Sample: BrowserBugs/Demos/legend.html:

                           

                          fieldset

                          legend {

                          font-weight:bold;

                          font-size:1.2em;

                          }

                          Password Reminder
                          http://www.learn-css-tutorial.com/BrowserIssues.cfm firefox: ok

                          fieldset

                          legend {

                          font-weight:bold;

                          font-size:1.2em;

                          }

                          ie7: not ok.

                          fieldset

                          legend {

                          font-weight:bold;

                          font-size:1.2em;

                          }

                          I add the following:  (here starts to confuse me!)

                           

                          but it does not show as what suppose to be expected.

                           

                          pls take a look.

                          Thanks in advance.

                          Patty

                           

                           

                           

                          • 10. Re: Can I have 2 on clicks in one form?
                            Albert S. Level 3

                            Hi Patti,

                             

                            You probably should start a new POST with this question. I am not the best at CSS and if more people see your new question you may get a better answer then I provide.