Jump to content

gevensen

Members
  • Posts

    206
  • Joined

  • Last visited

Posts posted by gevensen

  1. I have some routines I use over and over

    Is there a way to put the error section in a file of its own

     

    For example I use a routine below

     

    <script type="text/javascript">
    $('.MYTRIGGER').live('change', function() {
         
                var MyData=''; $("#jq_tab").val('0');
             var NameData=$(this).attr('name');
             var IdData=$(this).attr('id');
              MyData=MyData+'CID='+NameData;;
             MyData=MyData+'&Field='+IdData;
             MyData=MyData+'&FieldValue='+$(this).val();
                        
    
    
               
        $.ajax( { 
            cache:false, 
            timeout:28000, 
        url : 'MyPhp.php',
        type : 'post',
        data : MyData,
        success : function( resp ) {   
    $("#jq_tab").val('1');
    
    
        
        
    
    
           return(false); 
    
    
    
    
        },
    
    
        error: function(xhr, status, error) {
            var stat = $("#jq_tab").val();
        $("#main_page_div").unmask_div();
        if(stat!='1'){
         if (xhr.status === 0) {
                        alert('Unable to connect to Network');
                    } else if (xhr.status == 404) {
                        alert('Requested page not found. [404]');
                    } else if (xhr.status == 500) {
                        alert('Internal Server Error [500].');
                    } else if (exception === 'parsererror') {
                        alert('Requested JSON parse failed.');
                    } else if (exception === 'timeout') {
                        alert('System Timeout (Internet Congestion or server slow)');
                    } else if (exception === 'abort') {
                        alert('Ajax request aborted.');
                    } else {
                        alert('Unspecified Error #' + xhr.responseText);
                    }
        }
        return false;
        } // eof error function
        
        
        });  
           
                
    
    
            
    
    
    });
    </script>

    Since the below is common

     

    error: function(xhr, status, error) {
            var stat = $("#jq_tab").val();
        $("#main_page_div").unmask_div();
        if(stat!='1'){
         if (xhr.status === 0) {
                        alert('Unable to connect to Network');
                    } else if (xhr.status == 404) {
                        alert('Requested page not found. [404]');
                    } else if (xhr.status == 500) {
                        alert('Internal Server Error [500].');
                    } else if (exception === 'parsererror') {
                        alert('Requested JSON parse failed.');
                    } else if (exception === 'timeout') {
                        alert('System Timeout (Internet Congestion or server slow)');
                    } else if (exception === 'abort') {
                        alert('Ajax request aborted.');
                    } else {
                        alert('Unspecified Error #' + xhr.responseText);
                    }
        }
        return false;
        } // eof error function

    Is there a way to store the error function in a common file?

     

  2. Ive been working on this project for a few years its 117 tables per DB and about 10 DBs

    In development ive made changes to some of the tables

    The script i created a while back was missing an update here and there or i was forgetting

    Ive fixed that now I need to check the tables

    the array_diff was good

    what i did was compare the arrays from describe in both tables

    if(count(array_diff($a,$b)>'0') was greater than zero there's some kind of difference

    I don't care what difference at that point i take a sql dump of table b, rename table b in case of failure to xb, recreate table b from the structure of table a, import the sql dump and if all is well delete xb

    I had seen array_diff before but didnt think about taking a count of the arrays returned, where if it was greater than zero i had a problem

    just ran it on wamp and that seems to do the trick

    thanks mac_gyver for the thought

  3. Is there an easy way to compare the structure ( not data ) to see if 2 tables are identical?

     

    Ive used describe but im at the point where i have to loop thru the structure of each table

     

    I have a project with mutiple databases and tables and the tables in each db need to be identical

     

    I can create identical tables but im having an issue figuring out an easier way to simple compare 2 table structure

  4. try this

    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>
    
    
    <body>
    
    
    <?php
    $debug_message.="START DEBUG<br/>";
    $dbuser = "webestat_testdb";
    $dbpass = "password";
    $dbname = "webestat_testdb";
    $server = "localhost";
    $conn = mysqli_connect($servername, $dbuser, $dbpass, $dbname) or $debug_message.=mysqli_connect_error($conn)."</br>";
    
    
    if (!mysqli_error($conn))
    {
        $debug_message.= "Failed to connect to db" . mysqli_error($conn);
    } else {
    
    
    
    
    
    
    $sql = "SELECT * FROM 4000Series";
    
    
    $results = mysqli_query($conn, $sql);
    
    
    while($row = mysqli_fetch_assoc($results))
    {
    
    
        $debug_message.= "test";
       $debug_message.= $row['gpu']. " " .$row['khs']. " " .$row['usd'];
        $debug_message.= "<br>";
    }
    
    
    mysqli_close($conn);
    }
    echo $debug_message;
    ?>
    </body>
    </html>
    

     

    Ok, so I created a test database on my server, created 1 table with 1 row in it and the row is populated with values.

    I can connect to the database without error, but when I try to put in a while loop to print the results I get nothing but a blank screen.

    I tried placing some debug code in the while loop to see where its getting hung up but the while loop doesn't want to run at all. I placed an echo directly outside of the loop and the debug text is displayed fine but anything I put in the loop doesn't work.

    Can anyone help me out?

    Here is my code:

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <?php
    $dbuser = "webestat_testdb";
    $dbpass = "password";
    $dbname = "webestat_testdb";
    $server = "localhost";
    $conn = mysql_connect($server, $dbuser, $dbpass);
    
    if (!$conn)
    {
    	echo "Failed to connect to db" . mysql_error();
    }
    
    $selectdb = mysql_select_db('webestat_testdb', $conn);
    
    $sql = "SELECT * FROM 4000Series";
    
    $results = mysql_query($conn, $sql);
    
    while($row = mysql_fetch_assoc($results))
    {
    
    	echo "test";
    	echo $row['gpu']. " " .$row['khs']. " " .$row['usd'];
    	echo "<br>";
    }
    
    mysql_close($conn);
    ?>
    </body>
    </html>
    
  5. no i went thru it with a fine tooth comb so to speak

    I was definately not resetting the session

    This drove me nuts for about 2 months

    I finally had the time today to sit down and track it down

    The crazy thing was not everyone was affected.

    I shared the desktop of a person in Oklahoma and watched them go thru it a few min ago

    and it seems to be working perfect now

    This person was having major issues

    Go figure....

  6. I just got through a server problem with a variable named $_SESSION['id']

    What would happen was when I loaded a mysql request with id in it (usually what i name the main key in a table)

    it would overwrite the value in the $_SESSION without specifically asking it to ie $_SESSION['id']=$id;

    This was on an acenet server

    I have the same thing on a bluehost server and wampserver and never had a problem

    What I did on acenet was rename $_SESSION['id'] when declaring it to $_SESSION['usernumber'] and all my issues stopped

     

    Anyone know why?

     

    Is it a acenet problem?

     

    My problem is fixed im just wondering if anyone has had a similar issue?????

  7. check this out this something i am working on implementing

     

     

     

    Using phpmailer. this is all from here

     

    1)Download PHPMailer http://phpmailer.sourceforge.net/

     

    2) Extract to folder phpmailer

     

    3) Create a file email.php

     

    4) Paste this code and change the values in blue as you need (I modified the sample code given on the PHPMailer homepage)

     

    require("phpmailer/class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP(); // send via SMTP
    IsSMTP(); // send via SMTP
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "username@gmail.com"; // SMTP username
    $mail->Password = "password"; // SMTP password
    $webmaster_email = "username@doamin.com"; //Reply to this email ID
    $email="username@domain.com"; // Recipients email ID
    $name="name"; // Recipient's name
    $mail->From = $webmaster_email;
    $mail->FromName = "Webmaster";
    $mail->AddAddress($email,$name);
    $mail->AddReplyTo($webmaster_email,"Webmaster");
    $mail->WordWrap = 50; // set word wrap
    $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
    $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = "This is the subject";
    $mail->Body = "Hi,
    This is the HTML BODY "; //HTML Body
    $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
    if(!$mail->Send())
    {
    echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
    echo "Message has been sent";
    }
    ?>

    5) Open the file class.smtp.php in phpmailer directory

     

    6) Paste this code

     

    $host = "ssl://smtp.gmail.com";
    $port = 465;

    before the line 104 #connect to the smtp server Hint: Search for #connect

     

    7) Open this page in browser and it will send the email using GMail.

     

    Hint: When you want to email the details from a form, set the variables using the form variables. eg. $mail->Username=$_POST['email']

  8. ok yesterday i wrapped the decimal values like this, numbers are an example

    <?php
    $decimal1=2.50;
    $decimal2=2.50;
    if(strval($decimal1)!=strval($decimal2))(
    blah blah blah
    }
    ?>
    

     

    that worked

     

    if i am understanding the eplison thing i could also

     

    <?php
    $decimal1=2.50;
    $decimal2=2.50;
    $epsilon = 0.00001;
    
    if(abs($decimal1-$decimal2) < $epsilon) {
        echo "true";
    }
    ?>
    

     

    correct??

     

     

  9. I am comparing 2 decimal numbers I am pulling from a mysql file

    for ex

    $row[0]==$row1[0]

    every once in a while i get a bad positive when I do

    if($row[0]==$row1[0]) when they are exactly the same?

     

    One query is a SELECT amount FROM table

     

    the other is a select SUM(amount) FROM table2

     

    any ideas why?

     

    ive tried making them both abs()

     

    when I print the out they are =

     

     

  10. I am getting inconsistent results with

    var SWidth=$(window).width();

    var SCheight=$(window).height();

     

    I am running firefox 9

     

    sometimes it will read fine and then go from 1900x1200 to longer, sometimes 3487

     

    anybody run into this?

     

    then my browser window changes and I have to close the tab and reopen it to get the correct size again

     

     

    <script type="text/javascript">
    $(document).ready(function(){ 
    		var SWidth=$(window).width();
    		var SCheight=$(window).height();
    		$('#scw').val(SWidth);
    		$('#sch').val(SCheight);
    		var TWidth=SWidth*.95;
    		$('table.ccpaymenttable').attr('width', SWidth);
    		$('td.TDwidth').attr('width', TWidth);
    	});
    </script>

  11. Need to help on javascript addition

     

    I am retrieving a variable using the following

     

    i declare the variable either

    var TDIncome=parseFloat('0.00');

    or

    var TDIncome=0;

     

    I then add it inside a tr loop

    Where I convert the text MyInc to a float

     

    var MyInc=$(this).find("#incometd").text();
    TDIncome=TDIncome+parseFloat(MyInc);

     

    When I bring it up in an alert box I get NaN displayed

     

    Any ideas what I am doing wrong?

  12. i found a great function that seems to work fine

    <?php
    
    #
    # RFC3696 Email Parser
    #
    # By Cal Henderson <cal@iamcal.com>
    #
    # This code is dual licensed:
    # CC Attribution-ShareAlike 2.5 - http://creativecommons.org/licenses/by-sa/2.5/
    # GPLv3 - http://www.gnu.org/copyleft/gpl.html
    #
    # $Revision: 5039 $
    #
    
    ##################################################################################
    
    function is_rfc3696_valid_email_address($email){
    
    
      ####################################################################################
      #
      # NO-WS-CTL       =       %d1-8 /         ; US-ASCII control characters
      #                         %d11 /          ;  that do not include the
      #                         %d12 /          ;  carriage return, line feed,
      #                         %d14-31 /       ;  and white space characters
      #                         %d127
      # ALPHA          =  %x41-5A / %x61-7A   ; A-Z / a-z
      # DIGIT          =  %x30-39
    
      $no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]";
      $alpha  = "[\\x41-\\x5a\\x61-\\x7a]";
      $digit  = "[\\x30-\\x39]";
      $cr  = "\\x0d";
      $lf  = "\\x0a";
      $crlf  = "(?:$cr$lf)";
    
    
      ####################################################################################
      #
      # obs-char        =       %d0-9 / %d11 /          ; %d0-127 except CR and
      #                         %d12 / %d14-127         ;  LF
      # obs-text        =       *LF *CR *(obs-char *LF *CR)
      # text            =       %d1-9 /         ; Characters excluding CR and LF
      #                         %d11 /
      #                         %d12 /
      #                         %d14-127 /
      #                         obs-text
      # obs-qp          =       "\" (%d0-127)
      # quoted-pair     =       ("\" text) / obs-qp
    
      $obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]";
      $obs_text = "(?:$lf*$cr*(?:$obs_char$lf*$cr*)*)";
      $text  = "(?:[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|$obs_text)";
    
      #
      # there's an issue with the definition of 'text', since 'obs_text' can
      # be blank and that allows qp's with no character after the slash. we're
      # treating that as bad, so this just checks we have at least one
      # (non-CRLF) character
      #
    
      $text  = "(?:$lf*$cr*$obs_char$lf*$cr*)";
      $obs_qp  = "(?:\\x5c[\\x00-\\x7f])";
      $quoted_pair = "(?:\\x5c$text|$obs_qp)";
    
    
      ####################################################################################
      #
      # obs-FWS         =       1*WSP *(CRLF 1*WSP)
      # FWS             =       ([*WSP CRLF] 1*WSP) /   ; Folding white space
      #                         obs-FWS
      # ctext           =       NO-WS-CTL /     ; Non white space controls
      #                         %d33-39 /       ; The rest of the US-ASCII
      #                         %d42-91 /       ;  characters not including "(",
      #                         %d93-126        ;  ")", or "\"
      # ccontent        =       ctext / quoted-pair / comment
      # comment         =       "(" *([FWS] ccontent) [FWS] ")"
      # CFWS            =       *([FWS] comment) (([FWS] comment) / FWS)
    
      #
      # note: we translate ccontent only partially to avoid an infinite loop
      # instead, we'll recursively strip *nested* comments before processing
      # the input. that will leave 'plain old comments' to be matched during
      # the main parse.
      #
    
      $wsp  = "[\\x20\\x09]";
      $obs_fws = "(?:$wsp+(?:$crlf$wsp+)*)";
      $fws  = "(??:(?:$wsp*$crlf)?$wsp+)|$obs_fws)";
      $ctext  = "(?:$no_ws_ctl|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])";
      $ccontent = "(?:$ctext|$quoted_pair)";
      $comment = "(?:\\x28(?:$fws?$ccontent)*$fws?\\x29)";
      $cfws  = "(??:$fws?$comment)*(?:$fws?$comment|$fws))";
    
    
      #
      # these are the rules for removing *nested* comments. we'll just detect
      # outer comment and replace it with an empty comment, and recurse until
      # we stop.
      #
    
      $outer_ccontent_dull = "(?:$fws?$ctext|$quoted_pair)";
      $outer_ccontent_nest = "(?:$fws?$comment)";
      $outer_comment  = "(?:\\x28$outer_ccontent_dull*(?:$outer_ccontent_nest$outer_ccontent_dull*)+$fws?\\x29)";
    
    
      ####################################################################################
      #
      # atext           =       ALPHA / DIGIT / ; Any character except controls,
      #                         "!" / "#" /     ;  SP, and specials.
      #                         "$" / "%" /     ;  Used for atoms
      #                         "&" / "'" /
      #                         "*" / "+" /
      #                         "-" / "/" /
      #                         "=" / "?" /
      #                         "^" / "_" /
      #                         "`" / "{" /
      #                         "|" / "}" /
      #                         "~"
      # atom            =       [CFWS] 1*atext [CFWS]
    
      $atext  = "(?:$alpha|$digit|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])";
      $atom  = "(?:$cfws?(?:$atext)+$cfws?)";
    
    
      ####################################################################################
      #
      # qtext           =       NO-WS-CTL /     ; Non white space controls
      #                         %d33 /          ; The rest of the US-ASCII
      #                         %d35-91 /       ;  characters not including "\"
      #                         %d93-126        ;  or the quote character
      # qcontent        =       qtext / quoted-pair
      # quoted-string   =       [CFWS]
      #                         DQUOTE *([FWS] qcontent) [FWS] DQUOTE
      #                         [CFWS]
      # word            =       atom / quoted-string
    
      $qtext  = "(?:$no_ws_ctl|[\\x21\\x23-\\x5b\\x5d-\\x7e])";
      $qcontent = "(?:$qtext|$quoted_pair)";
      $quoted_string = "(?:$cfws?\\x22(?:$fws?$qcontent)*$fws?\\x22$cfws?)";
    
      #
      # changed the '*' to a '+' to require that quoted strings are not empty
      #
    
      $quoted_string = "(?:$cfws?\\x22(?:$fws?$qcontent)+$fws?\\x22$cfws?)";
      $word  = "(?:$atom|$quoted_string)";
    
    
      ####################################################################################
      #
      # obs-local-part  =       word *("." word)
      # obs-domain      =       atom *("." atom)
    
      $obs_local_part = "(?:$word(?:\\x2e$word)*)";
      $obs_domain = "(?:$atom(?:\\x2e$atom)*)";
    
    
      ####################################################################################
      #
      # dot-atom-text   =       1*atext *("." 1*atext)
      # dot-atom        =       [CFWS] dot-atom-text [CFWS]
    
      $dot_atom_text = "(?:$atext+(?:\\x2e$atext+)*)";
      $dot_atom = "(?:$cfws?$dot_atom_text$cfws?)";
    
    
      ####################################################################################
      #
      # domain-literal  =       [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
      # dcontent        =       dtext / quoted-pair
      # dtext           =       NO-WS-CTL /     ; Non white space controls
      # 
      #                         %d33-90 /       ; The rest of the US-ASCII
      #                         %d94-126        ;  characters not including "[",
      #                                         ;  "]", or "\"
    
      $dtext  = "(?:$no_ws_ctl|[\\x21-\\x5a\\x5e-\\x7e])";
      $dcontent = "(?:$dtext|$quoted_pair)";
      $domain_literal = "(?:$cfws?\\x5b(?:$fws?$dcontent)*$fws?\\x5d$cfws?)";
    
    
      ####################################################################################
      #
      # local-part      =       dot-atom / quoted-string / obs-local-part
      # domain          =       dot-atom / domain-literal / obs-domain
      # addr-spec       =       local-part "@" domain
    
      $local_part = "(($dot_atom)|($quoted_string)|($obs_local_part))";
      $domain  = "(($dot_atom)|($domain_literal)|($obs_domain))";
      $addr_spec = "$local_part\\x40$domain";
    
    
    
      #
      # see http://www.dominicsayers.com/isemail/ for details, but this should probably be 254
      #
    
      if (strlen($email) > 256) return 0;
    
    
      #
      # we need to strip nested comments first - we replace them with a simple comment
      #
    
      $email = rfc3696_strip_comments($outer_comment, $email, "(x)");
    
    
      #
      # now match what's left
      #
    
      if (!preg_match("!^$addr_spec$!", $email, $m)){
    
       return 0;
      }
    
      $bits = array(
       'local'   => isset($m[1]) ? $m[1] : '',
       'local-atom'  => isset($m[2]) ? $m[2] : '',
       'local-quoted'  => isset($m[3]) ? $m[3] : '',
       'local-obs'  => isset($m[4]) ? $m[4] : '',
       'domain'  => isset($m[5]) ? $m[5] : '',
       'domain-atom'  => isset($m[6]) ? $m[6] : '',
       'domain-literal' => isset($m[7]) ? $m[7] : '',
       'domain-obs'  => isset($m[8]) ? $m[8] : '',
      );
    
    
      #
      # we need to now strip comments from $bits[local] and $bits[domain],
      # since we know they're i the right place and we want them out of the
      # way for checking IPs, label sizes, etc
      #
    
      $bits['local'] = rfc3696_strip_comments($comment, $bits['local']);
      $bits['domain'] = rfc3696_strip_comments($comment, $bits['domain']);
    
    
      #
      # length limits on segments
      #
    
      if (strlen($bits['local']) > 64) return 0;
      if (strlen($bits['domain']) > 255) return 0;
    
    
      #
      # restrictuions on domain-literals from RFC2821 section 4.1.3
      #
    
      if (strlen($bits['domain-literal'])){
    
       $Snum   = "(\d{1,3})";
       $IPv4_address_literal = "$Snum\.$Snum\.$Snum\.$Snum";
    
       $IPv6_hex  = "(?:[0-9a-fA-F]{1,4})";
    
       $IPv6_full  = "IPv6\:$IPv6_hex(:?\:$IPv6_hex){7}";
    
       $IPv6_comp_part  = "(?:$IPv6_hex(?:\:$IPv6_hex){0,5})?";
       $IPv6_comp  = "IPv6\$IPv6_comp_part\:\:$IPv6_comp_part)";
    
       $IPv6v4_full  = "IPv6\:$IPv6_hex(?:\:$IPv6_hex){5}\:$IPv4_address_literal";
    
       $IPv6v4_comp_part = "$IPv6_hex(?:\:$IPv6_hex){0,3}";
       $IPv6v4_comp  = "IPv6\(?:$IPv6v4_comp_part)?\:\?:$IPv6v4_comp_part\?)$IPv4_address_literal";
    
    
       #
       # IPv4 is simple
       #
    
       if (preg_match("!^\[$IPv4_address_literal\]$!", $bits['domain'], $m)){
    
        if (intval($m[1]) > 255) return 0;
        if (intval($m[2]) > 255) return 0;
        if (intval($m[3]) > 255) return 0;
        if (intval($m[4]) > 255) return 0;
    
       }else{
    
        #
        # this should be IPv6 - a bunch of tests are needed here 
        #
    
        while (1){
    
         if (preg_match("!^\[$IPv6_full\]$!", $bits['domain'])){
          break;
         }
    
         if (preg_match("!^\[$IPv6_comp\]$!", $bits['domain'], $m)){
          list($a, $b) = explode('::', $m[1]);
          $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
          $groups = explode(':', $folded);
          if (count($groups) > 6) return 0;
          break;
         }
    
         if (preg_match("!^\[$IPv6v4_full\]$!", $bits['domain'], $m)){
    
          if (intval($m[1]) > 255) return 0;
          if (intval($m[2]) > 255) return 0;
          if (intval($m[3]) > 255) return 0;
          if (intval($m[4]) > 255) return 0;
          break;
         }
    
         if (preg_match("!^\[$IPv6v4_comp\]$!", $bits['domain'], $m)){
          list($a, $b) = explode('::', $m[1]);
          $b = substr($b, 0, -1); # remove the trailing colon before the IPv4 address
          $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
          $groups = explode(':', $folded);
          if (count($groups) > 4) return 0;
          break;
         }
    
         return 0;
        }
       }   
      }else{
    
       #
       # the domain is either dot-atom or obs-domain - either way, it's
       # made up of simple labels and we split on dots
       #
    
       $labels = explode('.', $bits['domain']);
    
    
       #
       # this is allowed by both dot-atom and obs-domain, but is un-routeable on the
       # public internet, so we'll fail it (e.g. user@localhost)
       #
    
       if (count($labels) == 1) return 0;
    
    
       #
       # checks on each label
       #
    
       foreach ($labels as $label){
    
        if (strlen($label) > 63) return 0;
        if (substr($label, 0, 1) == '-') return 0;
        if (substr($label, -1) == '-') return 0;
       }
    
    
       #
       # last label can't be all numeric
       #
    
       if (preg_match('!^[0-9]+$!', array_pop($labels))) return 0;
      }
    
    
      return 1;
    }
    
    ##################################################################################
    
    function rfc3696_strip_comments($comment, $email, $replace=''){
    
      while (1){
       $new = preg_replace("!$comment!", $replace, $email);
       if (strlen($new) == strlen($email)){
        return $email;
       }
       $email = $new;
      }
    }
    
    ##################################################################################
    ?>

     

     

  13. no... no alert at all... That code makes the 1st item liste to display blank page as well.

     

    then its something in your code because this works for me, i copied it out of a working module and just change the id

     

    make sure

    1) jquery is declared for example

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script src="jquery-1.4.2.min.js" type="text/javascript"></script>    
    <script>
    $('#yourtablename input[id^=pid_]:not(.ui-pid_)').live("click",function(){ 
    
    var idData = $(this).attr('id');
    var id_data=idData.split('_');
    $("#voucher_id").val(id_data[1]);
    alert(idData);
    
    });
    </script>
    </head>
    <body>
    

    you can find this stuff at http://jquery.com/

     

    create some html for example a table with some buttons named pid_1, pid_2, pid_3 ect and test to make sure you get that right then look in your code to see where the oopsey is

     

    this works for me i have used is quite a few times, maybe a hundred in various routines on my pages

     

    sometimes its the very obvious, a slip up in typing ect

     

    i use a debug line when im having trouble

     

    for ex

    $debug_message="START DEBUG</br>";

    $debug_message.=$whatever." = whatever</br>";

    $debug_message.="END DEBUG</br>";

    and after all is done the last line in my page is

    echo $debug_message;

    this has helped me find many a goof

     

     

     

  14. also if you want to make sure your not goofing something up before you start adding code use an alert box to test

    the below will create a popup and show the id data

    if you named the button id pid_whatever this will read it

    make sure you specify the table name and you have declared jquery in your incudes

     

    <script>
    $('#yourtablename input[id^=pid_]:not(.ui-pid_)').live("click",function(){ 
    
    var idData = $(this).attr('id');
    var id_data=idData.split('_');
    $("#voucher_id").val(id_data[1]);
    alert(idData);
    
    });
    </script>	

  15. Well I don't know much about jquery but if you need the form id="bd_itm" to process, then you'll need to have a unique value.  By just adding $id to the end should give you a unique id for each as in id="bd_itm'. $id . '" though not sure if that will be what you need.  Personally I'd just do a straight post to a processing page and direct them back to the product page, which will re-query and show items in their cart.

    once you get past the what in the world am i doing jquery basically supercharges php, no more page refreshes unless you want to

  16. this can also be used

     

    $('#yourtablename input[id^=pid_]:not(.ui-pid_)').live("click",function(){

     

    $('#yourtablename input[name^=pid_]:not(.ui-pid_)').live("click",function(){

     

    $('#yourtablename select[id^=pid_]:not(.ui-pid_)').live("click",function(){

     

    depending on if you use a id, name or <select > dropdown list

  17. i see your using jquery you can adapt this example, the jquery you showed in the 2nd post will not detect a dynamic list

     

    <script>
    $('#yourtablename input[id^=pid_]:not(.ui-pid_)').live("click",function(){ 
    
    var idData = $(this).attr('id');
    var id_data=idData.split('_');
    $("#voucher_id").val(id_data[1]);
    // do something
    
    });
    </script>	

  18. another thing you can try is to see if the id's are attaching themselves like you want

     

    for ex

     

    <input type="hidden" name="pid" id="pid_<?php echo $id?>" value="'. $id . '" title="pid_<?php echo $id?>" />

     

    would allow you to hover over it and see the id

     

    if the id's are correct i would assume the problem is somewhere else

     

    once your id's are correct and unique its a matter of detecting the click

     

    im not sure what your using but when I do it in jquery i use the live function for dynamic tables

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.