JavaScript to format SSN

Hello,
Im using Apex 4.1, Oracle 11g.
I have a simple page, and the requirement is to automatically format a SSN field to include dashes (-) should the customer only enter in all numbers.
I have written a javascript function to handle this, but no matter how I alter the substrings, the output is not correct.
Using the example below (with an onblur call on the element attribute) for an input of 123456789 returns: 123-3-5
<script type="text/javascript">
function FormatSSN() {
var SNN;
SSN = document.getElementById("P9_SSN").value ;
if (SSN.length == 9) {
document.getElementById("P9_SSN").value = SSN.substring(0,3) + "- " + SSN.substring(3,2) + "-" + SSN.substring(5,4);
</script>
Ive modified the values in the substring many times but none of the ouput makes any sense.
Can someone please advise.
Thank you,
Laura
Edited by: LauraK on Jun 5, 2012 10:06 AM

LauraK wrote:
Hello,
Im using Apex 4.1, Oracle 11g.
I have a simple page, and the requirement is to automatically format a SSN field to include dashes (-) should the customer only enter in all numbers.
I have written a javascript function to handle this, but no matter how I alter the substrings, the output is not correct.
Using the example below (with an onblur call on the element attribute) for an input of 123456789 returns: 123-3-5
<script type="text/javascript">
function FormatSSN() {
var SNN;
SSN = document.getElementById("P9_SSN").value ;
if (SSN.length == 9) {
document.getElementById("P9_SSN").value = SSN.substring(0,3) + "- " + SSN.substring(3,2) + "-" + SSN.substring(5,4);
</script>
Ive modified the values in the substring many times but none of the ouput makes any sense.
Can someone please advise.
Thank you,
LauraHave you considered using this Masked Text Field plug-in?
Edited by: fac586 on 05-Jun-2012 18:21
As to this:
Using the example below (with an onblur call on the element attribute) for an input of 123456789 returns: 123-3-5Notice the difference between the JS <tt>substring</tt> and <tt>substr</tt> methods. You want <tt>substr</tt> rather than <tt>substring</tt>.

Similar Messages

  • Javascript date format problem

    I want to get the current date assigned to a variable in the "YYYYMMDD" format using Javascript

    var date = new Date();
    var d  = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var month = (m < 10) ? '0' + m : m;
    var yy = date.getYear();
    var year = (yy < 1000) ? yy + 1900 : yy;
    document.write(year + month + day);btw: JavaScript is NOT Java.

  • CS3, PHP, Javascript: Auto-formatting phone number pre-post

    Hi guys and gals, I'm creating a simple user registration form, with a text field to have the user enter their phone number (this should autocorrect as the user types it). Grabbed a javascript snippet online, and I see whats going on in the code, but for some reason, its no workey
    Have 3 parts to the webpage, these are:
    The Javascript: "includes/ValidatePhone.js"
    // JavaScript Document
    <SCRIPT LANGUAGE="JavaScript">
    var n;
    var p;
    var p1;
    function ValidatePhone(){
    p=p1.value
    if(p.length==3){
         //d10=p.indexOf('(')
         pp=p;
         d4=p.indexOf('(')
         d5=p.indexOf(')')
         if(d4==-1){
              pp="("+pp;
         if(d5==-1){
              pp=pp+")";
         //pp="("+pp+")";
         document.form1.number.value="";
         document.form1.number.value=pp;
    if(p.length>3){
         d1=p.indexOf('(')
         d2=p.indexOf(')')
         if (d2==-1){
              l30=p.length;
              p30=p.substring(0,4);
              //alert(p30);
              p30=p30+")"
              p31=p.substring(4,l30);
              pp=p30+p31;
              //alert(p31);
              document.form1.number.value="";
              document.form1.number.value=pp;
    if(p.length>5){
         p11=p.substring(d1+1,d2);
         if(p11.length>3){
         p12=p11;
         l12=p12.length;
         l15=p.length
         //l12=l12-3
         p13=p11.substring(0,3);
         p14=p11.substring(3,l12);
         p15=p.substring(d2+1,l15);
         document.form1.number.value="";
         pp="("+p13+")"+p14+p15;
         document.form1.number.value=pp;
         //obj1.value="";
         //obj1.value=pp;
         l16=p.length;
         p16=p.substring(d2+1,l16);
         l17=p16.length;
         if(l17>3&&p16.indexOf('-')==-1){
              p17=p.substring(d2+1,d2+4);
              p18=p.substring(d2+4,l16);
              p19=p.substring(0,d2+1);
              //alert(p19);
         pp=p19+p17+"-"+p18;
         document.form1.number.value="";
         document.form1.number.value=pp;
         //obj1.value="";
         //obj1.value=pp;
    setTimeout(ValidatePhone,100)
    function getIt(m){
    n=m.name;
    //p1=document.forms[0].elements[n]
    p1=m
    ValidatePhone()
    function testphone(obj1){
    p=obj1.value
    //alert(p)
    p=p.replace("(","")
    p=p.replace(")","")
    p=p.replace("-","")
    p=p.replace("-","")
    //alert(isNaN(p))
    if (isNaN(p)==true){
    alert("Check phone");
    return false;
    </script>
    And then we have the actual PHP Form, "includes/Users_Insert.php":
    <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" enctype="multipart/form-data">
    <table>
         <th class="WADADataTableHeader">Phone Number:</th>
         <td>
              <input type="text" name="number" id="number" size="32" onclick="javascript:getIt(this)" />
              <?php echo $tNGs->displayFieldHint("number");?>
              <?php echo $tNGs->displayFieldError("Users", "number"); ?>
            </td>
         </tr>
          <tr>
              <td class="WADADataNavButtonCell" nowrap="nowrap">
              <input type="image" name="KT_Insert1" id="KT_Insert1" value="Insert record" src="../WA_DataAssist/images/Pacifica/Refined_insert.gif" />
           </td>
              <td class="WADADataNavButtonCell" nowrap="nowrap"><a href="users.php" title="Cancel">
                   <img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../WA_DataAssist/images/Pacifica/Refined_cancel.gif" /></a></td>
         </tr>     
    </table>
    And here is the calls to put all of that together, "add_user.php":
    <html><head><title></title>
    <script src="includes/ValidatePhone.js" type="text/javascript"></script>
    </head>
    <body>
    <?php include("includes/Users_Insert.php"); ?>
    </body>
    </html>
    (didn't paste the whole website obviously, just the parts that should be relevant).
    Anyone see anything in the code as to why this wouldn't be working as intended?

    You are not telling your form to validate the phone no.
    For a brief description of validating a form see - http://www.w3schools.com/jS/js_form_validation.asp
    Take special notice of - onsubmit="return validate_form(this)"
    PZ

  • XML format for Acrobat JavaScript

    Hi,
    This is my first posting to any Adobe forum, so please bear with me...
    I'm interested in the XML format for Acrobat JavaScript.  I'll be using an external editor (UltraEdit).  When I do (in Acrobat 8) Advanced-->Document Processing-->Edit All JavaScripts, UltraEdit starts off with this:
    //-----------------Do not edit the XML tags--------------------
    Interesting, but not very useful.  If I look at some existing PDF files containing JavaScript, I see things like:
    //-----------------Do not edit the XML tags--------------------
    //<Document-Level>
    //<ACRO_source>DocOpen</ACRO_source>
    //<ACRO_script>
    /*********** belongs to: Document-Level:DocOpen ***********/
    OK, this is better.  In fact, if I look at enough existing PDF files containing JavaScript, I could probably figure out the XML format by myself, including the XML format of tags like <Page-Actions>,  <AcroForm>, etc.  However, it would be far easier to get the specification of the JavaScript XML format -- for example, what is the format of the text following the "belongs to:" string within the various types of XML tags?
    I *presume* this is documented somewhere but I couldn't find it.  If someone has the Acrobat JavaScript XML format specification, it would be greatly appreciated.
    Thanks.
    Dave
    P.S. Another possible approach would be to create JavaScripts myself using Advanced-->Document Processing-->Document JavaScripts, and then see what XML is created based on the code I enter into the GUI, e.g. form code, functions, etc. This also seems somewhat inefficient, presuming again that the JavaScript XML format is already documented.

    Thanks for the additional information.
    I played with JavaScript some more, using my preferred editor, UltraEdit, which I attached to Acrobat.  I thought I would be able to take a JavaScript program from one PDF file (source file) and do a copy & paste into another PDF file (destination file).  While I can do the paste (again, via UltraEdit) into the destination file and can do an UltraEdit Save, when I go back into UltraEdit via Advanced --> Document Processing --> Edit All JavaScripts, the JavaScript I pasted from the source file to the destination file isn't there in the destination file.
    From this, I concluded that I'll need to create the Document-level JavaScript and the form field Javascripts (e.g. a JavaScript triggered by a "Mouse Down" in a button) via the Acrobat GUI's.  Acrobat doesn't seem to like it if I bypass the GUIs and just attempt to paste the code directly into the PDF file via an editor.  By not using the GUI and just doing the cut & paste as I did, I'm probably missing some part of the code setup/creation process that Acrobat needs to know about.
    This is why I originally asked about the syntax for the pseudo-XML, thinking I could just copy the pseudo-XML/JavaScript code from one PDF file to another, and then modify the code to reflect the needs of the destination PDF.  Now I understand the need you mentioned to use the Acrobat GUIs to set up the initial XML/JavaScript structure.
    Once I have the XML structure set up in the destination file (e.g. a JavaScript triggered by a "Mouse Down" in a button), I can obviously copy code snippets into that <AcroForm> sections, I just can't *create* the original "Mouse Down" <AcroForm> sections via the editor.
    Another approach I could follow would be to make a copy of the original source file and change the name of the copy to the desired destination file name, and then start modifying the code in the new (destination) file -- presuming that's the easiest path to get the desired functionality created.  This way, I wouldn't have to manually (via the Acrobat GUI) create all of the <Document-Level> and <AcroForm> sections.
    Thanks for your (and others') help, let me know if I'm missing anything.
    Dave

  • Javascript to duplicate every field

    Is there a way to duplicate every instance of a field in a document?
    I have a document with multiple fields (e.g. 'QTY.12345', 'QTY.12346', etc.) that occur in several places in the same document. Since I had no luck finding a way to set a field format to a non-javascript number format, I am trying to set up a script to duplicate every field wherever it exists in the document (the 'QTY.12345' field might exist on several pages, or more than once on the same page) and give the duplicated field the more advanced javascript functions.
    I can use the following to get every field in the 'QTY' family:
    var f = this.getField("QTY");
    var a = f.getArray();
    var v = 0.0;
    for (j =0; j < a.length; j++) {
    var fieldName = a[j].name
    app.alert ("Master field: " + fieldName)
    ...but I don't know how to find where each copy of the field exists in the document.
    My goal is to have a document which will give the user limited functionality if they have Javascript disabled, but will reveal the javascript enabled fields (and hide the non-js fields) and activate any javascript features on startup. When the file is closed, it will restore the document to the original non-javascript state.

    Hi,
    According to your description, there are three hidden fields in the NewForm page, users select a value in the “Customer” field. Before submit, you want to send a request
    to query the corresponding values for the three hidden fields, then perform the submit.
    Per my understanding, the logic of the code can be like this: hide the three fields after page loaded, in the PreSaveAction() function, use Client Object Model with
    CAML query to retrieve the item needed, set value to the three hidden fields, then submit.
    From your code, we can see that you are able to get/set value of fields in the NewForm page, retrieve item and extract the values needed in the query success callback
    function. Yes, you are in the right way.
    As you have accomplished all the main steps of this solution, in my opinion, the rest work would be to make them work smoothly together in your page for better user
    experience.
    Feel free to reply if there any question during the process.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Can a form variable hold a javascript complex object?

    I have a method in a fragmentScript script object that creates a javascript object formatted like below:
    customerObject
        name      [string]
        address  [string]
        city        [string]
        state      [string]
        list of accounts    [array]
    When the script is done executing, the subform containing the script gets hidden, and needs to pass the object to another subform which becomes visible. 
    Can I pass this object via a form variable (located under File-Form Properties, Variables tab)?  That is, can a form variable contain a complex javascript object?
    Thanks,
    Elaine

    Hey Bruce, I'm having a problem with the eval funtion returning a null, can you help me?
    Here's my code snippet:
    var tempRetCust = objFragment.resolveNode("returnCustomerObj");    //this is good  
    var objCustomer = myCustomerObject;     tempRetCust= objCustomer.toSource();     app.alert("tempRetCust "
    + tempRetCust);       //  the toSource method works great and the alert here returns proper data
    var retCust = eval(tempRetCust.value);   if (retCust==null ) app.alert ("return cust is null");     // the eval doesn't seem to work and the retCust variable is null.
    Thanks!
    Elaine

  • I want to format time in HTML-Client

    I have a lot of ftime fields in different tables. In Germany time is formated  in military format.
    The time is a number of Maximum 4 digits and is formated as follow.  130 Looks 01:30  1415 = 14:15 (2:15 pm)
    I wrote a Little Javascript to Format the number and this works fine.
    But I don't want to copy this in every postRender of every time in every Screen.
    Is there  possibility to do this with a Little custom control, or in worse case to attach the code below to a lot of times, without copy and pasting them.
    myapp.BrowseDisposaetze.ende_postRender = function (element, contentItem) {
    contentItem.dataBind("value", function (value) {
    if (value) {
    var str = "000"+value;
    str = str.substring(str.length-4);
    str = str.substr(0, 2) + ":" + str.substr(2);
    $(element).text(str);
    Helmut

    Hello Helmut,
    a custom control I'm not Aware of. I have the same ask for colouring values and I use a custom function.
    Make a new js-Script (maybe: GlobalFunction.js) file and put this into your Scripts Folder. Add this file to your Default.htm where the other js File live.
    In your file GlobalFUnction.js add
    function ConvertMilitaryTime(p1)
    var str = "000"+p1;
                    str
    = str.substring(str.length-4);
                    str
    = str.substr(0,
    2) +
    ":" + str.substr(2);
                   return str;}
    In your HTML Client Function call your new Function
    contentItem.dataBind("value",
    function (value)
    $(element).text = ConvertMilitaryTime(value);
    }Hope this helps
    Kind Regards
    Thomas

  • Unexpected result when parsing a datetime using sap.ui.core.format.DateFormat

    I am parsing datetime values in order to use them in an makit Chart.
    My x axis is a time axis with values in the JavaScript datetime format like 1408177125000.
    I wondered about a time shift in my axis and see the following result:
    console.log(Date(fValue) ): Thu Aug 28 2014 18:01:44 GMT+0200 (Mitteleuropäische Sommerzeit)
    console.log(oDateFormat.format(new Date(fValue))): 16.08.2014 11:23:33
    The date in line 01 is correct, the second one (16.8.) is not correct.
    I tried to simulate this behaviour in jsbin but there line 02 only states an error!?
    http://jsbin.com/sodetoyoqaba/1/edit?html,js,console
    I have no clue what is going wrong here. Any ideas?
    P.S. My app is running in SAP HCP Trial with sap.ui.version 1.22.6 while on jsbin it is version 1.22.7
    P.P.S When hitting the code manually in the jsbin console then I also get the wrong date 16.08.2014 there. So you can see the behaviour also there.

    That pretty much makes sense (although ignoring things is not very kind) 
    Good thing: Question is answered.
    Bad thing: The converted date is not what I expected from my datasource :-( At least I know where to search further now .
    Thanks,
    Mark

  • Accessing a arraylist in javascript

    Hi
    can anyone tell me how to access araraylist
    <table class="tableborder">
    <tr class="subtablerow2"><td class="boldtext">Total Marks : <bean:write name="courseCriteriaForm" property="totalMarks"/> </td>
    <td class="boldtext">Passing Marks : <bean:write name="courseCriteriaForm"property="passingMarks"/></td>
    </tr>
    </table>
    <table class="tableborder">
    <logic:iterate id="StudentListmarks" name="courseCriteriaForm" property="StudentListmarks" >
    <tr>
    <td>
    <bean:write name="StudentListmarks" property="userinfo_id"/>
    </td>
    <td>
    <bean:write name="StudentListmarks" property="firstname"/>
    </td>
    <td>
    <bean:write name="StudentListmarks" property="lastname"/>
    </td>
    <td>
    <html:text name="StudentListmarks" property="marks" indexed="true" />
    </td>
    <td>
    <html:text name="StudentListmarks" property="remarks" indexed="true"/>
    </td>
    </tr>
    </logic:iterate>
    </table>
    <div align="center"><html:submit styleClass="button" onclick=" return validate(this.form,StudentListmarks);"/><html:cancel styleClass="button" /></div>
    here is my javascript:
    function validate(form,myarraylist){
    alert("in the function........");
    for(var i=0;i<myarraylist.lenght;i++){
    alert("here....");
    return false;
    can any1 help me in validating marks by javascript

    a) Use formatting to display code
    b) dont use things like any1 , Why should people bother to help you if your question isent important enoigh to type 2 letters more ?
    c) As far as i know JavaScript does not have a build in ArrayList object

  • Web app Number field: How to format a number as currency in Business catalyst

    Not a coder. I have a Number field I have created in my web app, please how can I format this field to display the figures like this 999,999,999,999 (#120,000,000) random figure. Help will be appreciated.

    You can't. Number type field is there for storing integers. 999,999,999,999
    is not an integer. You need to use text string. Unless you're using the
    field inside the search form, in which case you need to use JavaScript to
    format the content of the field on the frontend.
    Cheers,
    Mario

  • OBIEE10G - Javascript problems with graphs

    Hi,
    Is there any known problem with using javascript and the display of graphs? I have a report where i have a pivot table where i use some javascript to format that table. Below that table i have 2 graphs that are different reports from the one with the pivot table (see images below).
    Version working well
    http://imageshack.us/f/41/graphworkingok.jpg/
    Version with problems
    http://imageshack.us/f/220/graphwithproblems.jpg/
    I guess the problems may be related with javascript because when i remove the javascript from the pivot table (i have it in a static text view) the graphs seem to work ok.
    I'm not an expert (far from that) with javascript and i was playing around with it so i could format the pivot table the way i wanted but i don't have enough knowledge of it to understand what may be causing the problem.
    Thanks

    I didn't do that because the line i want to format is a "manually" built line. I want to format the last line (total line) but that line wasn't made using the total feature of OBIEE but built by myself. What i do in that line is changing the background color of all the cells in that last line and changing the font-size as well.
    Would i be able to do this just by using CSS? From what i read i think i can't that's why i used JS.
    Btw, what i did is related to this other thread i created where i explained my problem, this may help:
    OBI10G - Format a specific cell of a pivot table
    Edited by: Pedro F on 19/Mar/2012 4:15

  • Form doesn't submit [was: Please Help!]

    I am new to web development and am obviously just not seeing what I'm missing. I re-built our company's website in January (mostly because of over-charging by our webmaster). It is an exceptionally basic .html sight but it works for us. I have learned a great deal about coding the basics and have been slowly going back through my orginal pages and cleaning up the code. While I was doing that I noticed that one of the pages our customers use are from our old website. I am trying to create a form that I will be able to manipulate that has the look and feel of our current site. Maybe you can take a look and explain to me why when I fill in all the required fields and hit the "submit" button nothing happens.
    http://http://langsauction.com/Staging/bid_form_test.html
    Our server has a cgi folder that has not been touched or moved so I am guessing I just haven't figured out where to add the code I need for this to work.
    I have checked the code from our old page:
    http://https://langs11.securesites.net/bids/index.php/
    Other than it being a .php I can't see what I missed.....
    When the information is submitted from the "old" page it is stored on our server and I receive an email notification, I click the link in my email and am directed to a printable page with all of our customer's information. I would like the same thing to happen with my new page.
    I really appreciate any help you can give me!
    Christina
    Subject line edited by moderator to indicate nature of problem

    You have been huge help already....I am taking your advise and walking away for this evening.....if you could look into this I would be eternally greatful!!
    <?php
    * Things to NOTE
    * Is it ok to have month values as numbers in this format 01, 02, 03, ... 11... etc..
    require_once 'https://langsauction.com/bids/Crypt_Blowfish-1.0.1/Blowfish.php';
    include('https://langsauction.com/bids/functions.php');
    include('https://langsauction.com/bids/db.php');
    $b = new Crypt_Blowfish('5az1bc1dDa1cv1TVa1wQa12xXx');
    # for new crypt method
    $key = "5az1bc1dDa1cv1TVa1wQa12xXx";
    $error_fields = array();
    $errors = array();
    # passed to function month_display and will print out relevant values
    $***_month = array("01" => "January", "02" => "February", "03" => "March", "04" => "April", "05" => "May", "06" => "June", "07" => "July", "08" => "August", "09" => "September", "10" => "October", "11" => "November", "12" => "December");
    $***_fields = array("last_name" => "Last Name", "first_name" => "First Name", "address1" => "Address 1", "city" => "City", "state" => "State / Province", "zip" => "Zip / Postal Code", "county" => "County", "country" => "Country", "phone" => "Telephone", "email" => "Email", "cc_type" => "Credit Card Type", "cc_name" => "Names As It Appears On Card");
    # keeps track of which fields had errors so
    # it's html row can be highlighted
    $error_fields = array();
    * Credit Card Validation Solution, PHP Edition,
    * Usage Example.
    * @package    CreditCardValidationSolution
    * @author     Daniel Convissor <[email protected]>
    * @copyright  The Analysis and Solutions Company, 2002-2003
    * @version    $Name: rel-5-12 $ $Id: ccvs_example.php,v 1.15 2003/08/06 05:51:57 danielc Exp $
    * @link       http://www.ccvs.info/
    * Require the main file.
    require('../Documents/Langsauction/www/langsauction.com/bids/ccvs.inc.php');
    $Form = new CreditCardValidationSolution;
    * Example of to encrypt and decrypt
    $encrypted = $b->encrypt('test');
    $decrypted = $b->decrypt($encrypted);
    echo " encr - $encrypted - decryp $decrypted";
    #echoÊ"Encrypted:Ê" .Êbin2hex($encrypted)Ê.Ê"\n";
    # existing code
    if (isset($_POST['submit'])) {
        dbConnect('langsa');
    * Need to Still
    * run all fields through POST VARS
    * and sanitize data
    * use reg match from metrochai validation
    # check user has checked Conditions of Sale
    if($_POST['agree'] != 'yes') {
        array_push($errors, '>>Please read and accept the Conditions of Sale by selecting the checkbox');
    foreach ($***_fields as $field => $field_name) {
        if($_POST[$field] == '') {
          array_push($error_fields, $field);
          array_push($errors, '>>The "'. $field_name . '" Field is empty. Please enter information for that field');
    * Check that if a user enters a value in the Lot No. field, that all other fields in that row also have values
    for($x = 1; $x < 16; $x++) {
         if( $_POST['lot' . $x] != '' && ( $_POST['lot_desc' . $x] == '' ||  $_POST['lot_max' . $x] == '' ||  $_POST['lot_max_bid' . $x] == '' ) ) {
          $lot = 'lot' . $x;
          $lot_name = 'Lot No. ' . $_POST['lot' . $x];
          array_push($error_fields, $lot );
          array_push($errors, '>>Please fill in the additional values for  "'. $lot_name . '" in STEP 3');
         * Put the names of the card types you accept in here.
         * To handle all card types, skip this step and put ''
         * in the Accepted argument.
        $Accepted = '';
        $Month = $_POST['exp_dat_mon'];
        $Year  = $_POST['exp_dat_yea'];
        # adding trim to remove any spaces at beginnning or end
        # in order to keep live server from breaking on mysql syntax
        $_POST['cc_num'] = trim($_POST['cc_num']);
    # check if Credit Card Number is empty
    if (empty($_POST['cc_num']) ) {
                # if CC Num is blank along with other relevant fields
                $Form->CCVSNumber = '4002417016240182';
                $Month = '';
                $Year  = '';
                array_push($errors, '>>The "Credit Card Number" Field Is Blank. Please enter information for that field');
    # if Credit Card Number is not empty then check integrity of numbers   
    elseif ( !$Form->validateCreditCard($_POST['cc_num'], 'en', $Accepted, 'Y', $Month, $Year) ) {
             array_push($errors, $Form->CCVSError);
             array_push($error_fields, 'cc_num');                
    $count_errors = count($errors);
    if($count_errors == 0) {
    # form appears to be good so process data
    # encrypt credit card info
    # PEAR Blowfish Object Call
    #$cc_num = $b->encrypt($_POST['cc_num']);
    $cc_num = encrypt($_POST['cc_num'], $key); //encrypts the data using the key
    //echo "$encrypted<hr>";
    #sanitize data
        $email = strip_invalid_chars($_POST[email], 'email');
         $last_name = strip_invalid_chars($_POST[last_name]);
         $first_name = strip_invalid_chars($_POST[first_name]);
         $address1 = strip_invalid_chars($_POST[address1]);
         $address2 = strip_invalid_chars($_POST[address2]);
        $city = strip_invalid_chars($_POST[city]);
        $state = strip_invalid_chars($_POST[state]);
        $zip = strip_invalid_chars($_POST[zip]);
        $county = strip_invalid_chars($_POST[county]);
        $country = strip_invalid_chars($_POST[country]);
        $phone = strip_invalid_chars($_POST[phone], 'insecure');
        $cc_type = strip_invalid_chars($_POST[cc_type]);
        $cc_name = strip_invalid_chars($_POST[cc_name]);
        $exp_dat_yea = strip_invalid_chars($_POST[exp_dat_yea]); 
        $exp_dat_mon = strip_invalid_chars($_POST[exp_dat_mon]);
        $sql = "INSERT INTO cc_form SET
                  last_name= '$last_name',
                  first_name = '$first_name',
                  address1 = '$address1',
                  address2 = '$address2',
                  city = '$city',
                  state = '$state',
                  zip = '$zip',
                  county = '$county',
                  country = '$country',
                   phone = '$phone',
                  email = '$email',
                  cc_type = '$cc_type',
                  cc_num = '$cc_num',
                  exp_dat_mon = '$exp_dat_mon',
                   exp_dat_yea = '$exp_dat_yea',
                  cc_name = '$cc_name',
                  date = NOW()";
              $insert_cc_data = mysql_query($sql) or die(mysql_error()) ;
              # get id for lots table
              # to keep track of each user's lots
              $id = mysql_insert_id();
             * Insert Lots
            foreach ($_POST as $key => $val) {
                # sanitize data in all fields in loops
                if (preg_match("/lot([0-9]+)/", $key,  $matches)) {
                #echo "-- $matches[0]";
                if($_POST['lot'.$matches[1]] != '') {
            $val_lot = strip_invalid_chars($_POST['lot'.$matches[1]]);
            $val_lot_desc = strip_invalid_chars($_POST['lot_desc'.$matches[1]]);
            $val_lot_max = strip_invalid_chars($_POST['lot_max'.$matches[1]]);       
            // looks like strip_invalid_chars with type 'all' was stripping out '.' and perhaps the comma from
            // the javascript that formatted the number eg: 1,204.02
            // will now set type 'insecure' for strip_invalid_chars, which should leave '.' and , commas intact
            // for now will leave the lot_max_bid field as a varchar and have the javascript do the formatting
            // NOTE if the user's browser does not have javascript enabled
            // then currency will not be formatted into the database
            // would need to check entries for a '.' and if not found then use php currency formatting function
            $val_lot_max_bid = strip_invalid_chars($_POST['lot_max_bid'.$matches[1]], 'insecure');
            if(!preg_match("/./", $val_lot_max_bid)) {
                //$val_lot_max_bid = number_format($val_lot_max_bid, 2, '.', ',');
                        #echo $val_lot . "<br />";
                        #echo $val_lot_desc  . "<br />";
                        #echo $val_lot_max . "<br />";
                        #echo $val_lot_max_bid . "<br />";
                    $query_lots = "INSERT
                             INTO
                                    lots
                                    (lot_nu,
                                     lot_desc,
                                     lot_max,
                                     lot_max_bid,
                                     user_id,
                                     date
                                    values(
                                    '" . $val_lot . "',
                                    '" . $val_lot_desc . "',
                                    '" . $val_lot_max . "',
                                    '" . $val_lot_max_bid . "',
                                    '$id',
                                    NOW()
                #v_dump($matches[1]);
                $insert_lots = mysql_query($query_lots) or die(mysql_error());
               } # end of if isset
         * Make Sure Duplicate Entries Don't Occur
         * When User Hits Refresh Here
    ?>
        <html>
      <head>
        <title>Lang's Bids</title> 
    <script type="text/javascript" src="../Documents/Langsauction/www/langsauction.com/bids/site.js"></script>
    <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">      
      </head>
    <body>
        <center>
        <table width="750">
            <tr>
                <td valign="center"><img src="https://langs11.securesites.net/bids/images/Bid-Banner.jpg">
                <br />
        <font size="-1" face="Verdana, Arial, Helvetica"><p><ul>Your Absentee Bid Information Was Received. Thank You.</ul></p>
        <p><ul><a href="javascript:window.close()">Close Window</a></ul></p></font>
                   </td>
               </tr>
        </table>
        </center>
        </body>
        </html>
    <?php
       * Send Email
      $today = date("F j, Y, g:i a");
      //$to = "[email protected]";
      //$to = "[email protected]";
      //$to = "[email protected]";
      // current email address to use!
      $to = "[email protected]";
      //$to = "[email protected]";
      $from = "[email protected]";
      $subject = "A Lang's Absentee Bid Has Been Submitted - " .$today. "";
      $message = "A Lang's Absentee Bid Has Been Submitted on " .$today. "\n\n Visit the Admin Area to view this entry:\n\nhttps://langs1.securesites.net/lang_cc/index.php";
      $headers = "From: $from\r\n";
      $send = mail($to, $subject, $message, $headers);
      exit;
    } # end of submit
        ?>
    <html>
      <head>
        <title>Lang's Bids</title>
             <LINK REL="StyleSheet" HREF="../Documents/Langsauction/www/langsauction.com/bids/bids.css" TYPE="text/css">
    <SCRIPT LANGUAGE="JavaScript">
    <!--http://javascript.internet.com/forms/currency-format.html-->
    <!-- Begin
    function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    //return (((sign)?'':'-') + '$' + num + '.' + cents);
    return (((sign)?'':'-') +  num + '.' + cents);
    //  End -->
    </script>
    <style type="text/css">
      .disclaimer {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 14px;
        color: #000;
        margin: 0px;
        padding: 0px;
      .heading {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 30px;
        color: #6A0000;
      .buttons {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 54px;
      .footer {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 16px;
        line-height: 1px;
        font-style: italic;
      .tabletitles {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 14px;
      </style>
      </head>
      <!-- body -->
    <body>
    <form  name=currencyform method="post" action="<?=$_SERVER['../Documents/Langsauction/www/langsauction.com/bids/PHP_SELF']?>#for m_start">
    <center>
    <table width="750" border="0" cellpadding="0" cellspacing="5" class="text">
        <tr>
            <td colspan="2" align="center"><img src="Auction Banner.jpg" width="960" height="255" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
        <br>
        <center>
        <font face="arial" size="3">
        <span class="heading">Absentee and Phone Bid Form </span><br>
        </font>
        </center>
        <div align="center"><br>
          <span class="disclaimer">IMPORTANT: Please read CONDITIONS OF SALE before filling out form.<br><br>
            <strong>Absentee Bidding:</strong> Please complete this form to absentee bid on any lots (catalog item numbers) in this auction. Absentee bids are executed on your behalf by our staff in competition with bids from other bidders. In the event two identical absentee bids are received, the bid first received will be accepted. In the event your maximum bid ties with a bid from the phone, the normal policy is to go one increment higher on your behalf to break the tie in your favor. If you want us to do so, PLEASE INDICATE +1 ON THE FORM, IF NOT, PLEASE INDICATE MAX. <br><br>
            <strong>Phone Bidding:</strong> If you want to bid on the phone, through a member of Lang’s staff during the auction, please indicate so on this form along with the numbers of the lots you intend to bid on. Be sure to indicate the phone numbers where Lang’s can call you when it’s time for you to bid. We will make every effort to execute all absentee and phone bids. However, if there is an error or omission, Lang’s will not be held liable. <br><br>We require a good faith deposit equal to 20% of the maximum total bid (bank check, money order or VISA/Master Card).
            An 18% buyer’s premium will be added to all successful bids. A 3% discount (resulting in 15%) is given for cash or check payments.
      <br><br>
      <strong>Invoices will be emailed at the close of the auction on Sunday night to the email address provided.</strong><br> Please check your Spam folder or contact Lang’s office if you do not receive your invoice.<br><br>
            ~MAKE CHECKS PAYABLE TO LANG’S ~ Payment is due in full within ten days following the auction.
            Failure to pay within ten days following the auction will jeopardize future absentee & phone bidding privileges.
            </span><br><br>
          <hr width="100%" size="3" />
        </div>
        <p></p>
            </td>
        </tr>
        <tr>
          <td colspan="2">
          <a name="form_start">
            <br />
            <?php
            $error_count = count($errors);
            if($error_count > 0) {
              echo "<font face=\"arial\" color=\"red\" size=\"2\">";
              echo "The Following Errors Occured:<br /><br />";
            #  $errors = $_GET['errors'];
              foreach ($errors as $error_item) {
                  echo "$error_item<br />";
              echo "</font>";
            } # end of if error_count
              ?>     
          </td>
        </tr>
           <tr>
            <td colspan="2"></td></tr>
        <tr <?php if(in_array('first_name', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>First Name     </p>
            </td>
            <td align="left" width="550">
                <input name="first_name" type="text" value="<?=$_POST['first_name']?>"  maxlength="100" size="25" />
                <font color="orangered"><b>*</b></font>
            </td>
        </tr>
        <tr <?php if(in_array('last_name', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left" <?php if(in_array('last_name', $error_fields)) { echo "class=\"signupform\"";}?>>
                <p>Last Name     </p>
            </td>
            <td align="left">
                <input name="last_name" type="text" value="<?=$_POST['last_name']?>" maxlength="100" size="25" />
                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr>
            <td align="left" <?php if(in_array('address1', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
                <p>Address 1     </p>
            </td>
            <td align="left">
                <input name="address1" type="text" value="<?=$_POST['address1']?>" maxlength="100" size="25" />
                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr>
            <td align="left">
                <p>Address 2     </p>
            </td>
            <td align="left">
                <input name="address2" type="text" value="<?=$_POST['address2']?>"     maxlength="100" size="25" />
            </td>
        </tr>
        <tr valign="top" <?php if(in_array('city', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>City     </p>
            </td>
            <td align="left">
                 <input name="city" type="text" value="<?=$_POST['city']?>"  maxlength="100" size="25" />
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr valign="top" <?php if(in_array('state', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>State / Province     </p>
            </td>
            <td align="left">
      <!--     
    <select name="state" class="text">    
      <option value="<?php echo isset($_POST['state']) ? $_POST['state'] : ""; ?>"><?php echo isset($_POST['state'])  ? $_POST['state'] : "Select State"; ?></option>   
    <?php echo QAstatelist($vars['state']); ?>"
                                        </select>
    -->
            <input name="state" type="text" value="<?=$_POST['state']?>"  maxlength="100" size="25" />
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr valign="top" <?php if(in_array('zip', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Zip / Postal Code     </p>
            </td>
            <td align="left">
                 <input name="zip" type="text" value="<?=$_POST['zip']?>"  maxlength="100" size="25" />
                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <!-- adding Country -->
         <tr valign="top" <?php if(in_array('country', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Country     </p>
            </td>
            <td align="left">
                 <input name="country" type="text" value="<?=$_POST['country']?>"  maxlength="100" size="25" />
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
         <tr valign="top" <?php if(in_array('phone', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Telephone     </p>
            </td>
            <td align="left">
                 <input name="phone" type="text" value="<?=$_POST['phone']?>"  maxlength="100" size="25" />
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr valign="top" <?php if(in_array('email', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>eMail     </p>
            </td>
            <td align="left">
                 <input name="email" type="text" value="<?=$_POST['email']?>"   maxlength="100" size="25" />
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
          <tr valign="top" <?php if(in_array('cc_type', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Credit Card Type     </p>
            </td>
            <td align="left">
        <select name="cc_type" size="1">
             <option value="<?=$_POST['cc_type']?>"><?php echo isset($_POST['cc_type']) ? $_POST['cc_type'] : "Select Type"; ?></option>   
             <option value="Visa">Visa</option>
             <option value="MasterCard">MasterCard</option>
        </select>
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr <?php if(in_array('cc_num', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Credit Card Number     <br /></p>
            </td>
            <td align="left">
                <input name="cc_num" type="text" value="<?=$_POST['cc_num']?>" maxlength="100" size="25" />
                <font color="orangered" size="+1"><tt><b>*</b></tt><br /><font face="arial" size="1" color="#FF0000"><b>(numbers only, no dashes please)</b></font></font>
            </td>
        </tr>
         <tr <?php if(in_array('exp_dat_mon', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?><?php if(in_array('exp_dat_yea', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Expiration Date     </p>
            </td>
            <td align="left">
               <select name="exp_dat_mon" size="1">
                 <?php if(!isset($_POST['exp_dat_mon'])) { echo "<option value=\"\">Select Month</option>";}?>
             <?php echo month_display($***_month, $_POST['exp_dat_mon']); ?>"
           </select>
            <select name="exp_dat_yea" size="1">
                 <option value="<?=$_POST['exp_dat_yea']?>"><?=$_POST['exp_dat_yea']?></option>
                 <option value="2008">2008</option>
                 <option value="2009">2009</option>
                 <option value="2010">2010</option>
                 <option value="2011">2011</option>
                 <option value="2012">2012</option>
                 <option value="2013">2013</option>
                 <option value="2014">2014</option>
                 <option value="2015">2015</option>
                 <option value="2016">2016</option>
                 <option value="2017">2017</option>
                 <option value="2018">2018</option>
                 <option value="2019">2019</option>
                 <option value="2020">2020</option>
                 <option value="2021">2021</option>
                 <option value="2022">2022</option>
           </select>
            <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr <?php if(in_array('cc_name', $error_fields)) { echo "bgcolor=\"FFCCCC\"";}?>>
            <td align="left">
                <p>Names As It      <br />
            Appears On Card     </p>
            </td>
            <td align="left">
                <input name="cc_name" type="text" value="<?=$_POST['cc_name']?>"  maxlength="100" size="25" />
                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <table width="640">
            <tr><td colspan="4"><hr noshade="noshade" /></td></tr>
            <tr><td colspan="4"><font face="arial" size="3" color="#FF0000">STEP 3</FONT></td></tr>
                           <tr>
                <td align="left" valign="top" class="tabletitles">LOT No.</td>
                <td align="left" valign="top" class="tabletitles">DESCRIPTION</td>
                <td align="left" valign="top" class="tabletitles">MAX, +1 or PHONE</td>
                <td align="left" valign="top" class="tabletitles">BID AMOUNT</td>
                        </tr>
              <?php
              for($x = 1; $x < 16; $x++) {
              ?>
                   <tr>
                <td>
                <input name="lot<?=$x?>" type="text" value="<?=$_POST['lot' . $x]?>"  maxlength="90" size="15" />
                </td>
                <td>
                <input name="lot_desc<?=$x?>" type="text" value="<?=$_POST['lot_desc' . $x]?>" maxlength="100" size="50" />
                </td>
                <td>
                <input name="lot_max<?=$x?>" type="text" value="<?=$_POST['lot_max' . $x]?>" maxlength="90" size="30" />
                </td>
                <td>
                <input type=text name="lot_max_bid<?=$x?>" maxlength="90" size="30" value="<?=$_POST['lot_max_bid' . $x]?>" onBlur="this.value=formatCurrency(this.value);">
        <!-- old input field without javascript currency formatter
                    <input name="lot_max_bid<?=$x?>" type="text" value="<?=$_POST['lot_max_bid' . $x]?>"  />
        -->
                </td>
                </tr>
              <?php
              ?>
            </table>
            </td>
        </tr>
        <tr>
            <td colspan="2">
             <p><br /><br /><p>
                 <input type="checkbox" name="agree" value="yes" <?php if($_POST['agree'] == 'yes') { echo "checked";}?>> <b>I have read and accept the <a href="http://langsauction.com/CONDITIONS OF SALE.pdf" target="_blank"><font color="#FF0000">Conditions of Sale (required)</b></a>
             </p>
             <br />
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2">
                <hr noshade="noshade" />
                <input type="reset" value="Reset" />
                <input type="submit" name="submit" value="Submit " />
            </td>
        </tr>
    </table>
    </center>
    </form>
    <br>
    <hr width="100%" size="3" /><br>
    <p align="center" class="footer">Lang's Auction, Inc. &#8226; 663 Pleasant Valley Road &#8226; Waterville, NY 13480 </p>
    <p align="center" class="footer">Phone: 315-841-4623 &#8226; Fax: 315-841-8934 &#8226; <a href="mailto:[email protected]">[email protected]</a></p>
        <br />
        <hr width="75%" size="3" />
        <p align="center" class="footer">     </p>
    <div align="center"><i>&copy; 2012 Lang's Auction, Inc. All rights reserved.</i></div>
        </p>
      <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-17131030-1']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </body>
    </html>
    <!--- table bottom of main body content -->

  • Can't load Facebook on Firefox . Suspect malware/trojan. Downloaded 3 free scan/remove programs, all end in .exe and my Mac wants to know which "Application" to use to run them. Help?!

    Firefox 3.6.19
    Mac OS 10.4.11
    attempted the''' 3 free options''' listed here
    http://support.mozilla.com/en-US/kb/Firefox%20never%20finishes%20loading%20certain%20websites?s=cannot+load+page&as=s
    when I click on any of them, they don't just open/run. they want to know what application to use to open them. do these work for my Mac, or is there another free alternative?
    Here's what the Mozilla page above said
    Firefox never finishes loading certain websites
    If specific websites (not all) start to load, but never finish (i.e. The Firefox activity indicator may spin for several minutes, or the status bar may show "Done" on a blank page), it is either because of a software trojan called Vundo, or a file being in the wrong format.
    Table of Contents
    * Vundo trojan variant
    o Search for malware
    o More help
    * JavaScript file format
    Vundo trojan variant
    A variant of the Vundo trojan is known to cause Firefox to have problems loading certain high-traffic sites, including Google, Yahoo, MySpace, Facebook, and more.
    Search for malware
    Not all variants of the Vundo trojan can be detected or removed by malware scanners. However, you should scan your computer for infections first:
    * Run the Microsoft Malicious Software Removal Tool.
    * Run a full system virus scan with something other than your normal program:
    o A '''free solution online is Kaspersky's online scanner'''.
    * Run a full system spyware scan with something other than your normal program:
    o MalwareBytes' Anti-Malware
    o '''SUPERAntiSpyware''' is known to detect many variants of Vundo, and has a free version.
    o '''Spybot S&D''' is a well-known free solution.
    More help
    If you're having a problem loading sites other than the one described above, see the Error loading websites article to see if it addresses your problem. You can also check your Internet security software - resetting permissions for Firefox can often fix similar problems.
    There can be other causes of the symptoms described above. Before attempting these instructions, try the methods described in the Basic Troubleshooting article to see if they will address your problem.
    If you still have problems after scanning, you may ask a support question.

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • [CS4/JS] Pnglib.jsx -- A PNG creator function

    After seeing Marc Autret's marvellous pngswatch script, I spent several hours creating PNGs with Photoshop, copying its hex data into Javascript compatible format, finding the relevant color bytes to change ... and all the while I was thinking, "there was an uncompressed PNG format, wasn't there?"
    That's not because I have a bad memory.
    Sure, Marc created his PNG in some other program, saved it as a compressed file, and 'only' changed the palette part in his script -- which involves delving quite deeply into the actual PNG format --, and that's a feasible way of doing the stuff he intended to: change jsut the color. But if you want to actually create a dropdown or listbox image on the fly -- say, for a line widths dropdown --, you have to be able to create an entire image a-new. And PNGs are notoriously difficult to create, because the image pixels themselves are compressed using the very advanced zlib compression.
    But (as I was thinking) ... zlib also allows a "non-compressed" format!
    With some sleuthing I found a couple of hints to get me started, and found a totally useful utility as well: pngcheck, which can take a PNG to bits and tell you what's wrong with it. So, here you have it: a lightweight PNGLIB Javascript, that can create any PNG right out of nothing!
    Any image, apart from the limitations, that is.
    Its main limitation is that you can only create 8-bit palettized PNGs with it. I see no reason to add umpteen functions to cater for the occasional 1-, 2-, or 4-bit or true color PNG, or to add total support for all the different types of transparency that PNG supports. But, hey, its main use is for icons, and you'll have to do with the limits of "just" 256 colors -- or even less than that, if you reserve one or more colors for transparency. On the plus side again, it's total real pixel alpha-level transparency we're talking about (overall that can make your graphics still better than the average '90s DOS game).
    Using the function is easy; at the bottom of the script is an example, but it boils down to:
    Create a string for the palette's colors. Each color is a triplet, in RGB order.
    Create a string for the transparency indexes. Each single entry determines the transparency of the full palette color at that index; the first entry applies to color index #0, the second to color index #1, and so on. The value [00] indicates zero opacity (fully transparent), the value [FF] full opacity. The transparency index string doesn't need to define all of your colors' transparencies; unlisted values are "normal", non-transparent, and if you only need to make color index #0 transparent, you are done right there and then. By the way, the transparency string may be omitted entirely if you don't need it.
    Create a string for the image itself -- wide x high color indexes. Make sure you fill the entire image, 'cause my function will refuse to work if this string length isn't correct.
    Then call my function: myImg = makePng (wide, high, palette, pixels [, transparency]);
    The returned string can be used immediately as a source for a ScriptUI dialog image, or -- less useful, but might come in handy -- be written to a file.
    Tips: hmm. I dunno. Don't use this function to create super-huge PNGs, I guess. The non-compression format uses a couple of checksums on its own, and they are sure to fail on very large images. But, come on, be realistic: it's not a Photoshop replacement we're talking about, it's for icons!
    And Be Kind to Your Users: it's rather overkill to include all of the data for a static PNG image, such as a logo or something. Just create that once, and include the binary data in your script! This function is designed to create PNGs on the fly, from variable rather than static data.
    Before I forget: here it is. Enjoy!
    /****** PngLib.jsx ******/
    /* A Jongware Product -- based *very* heavily, however, upon Marc Autret's pngswatch
    /* script (http://forums.adobe.com/thread/780105?tstart=0), and with further
    /* help from the pages of David "Code Monk" Jones (http://drj11.wordpress.com/2007/11/20/a-use-for-uncompressed-pngs/)
    /* and Christian Fröschlin (http://www.chrfr.de/software/midp_png.html)
    /* Any errors, of course, must have crept in while I wasn't paying attention.
    /* [Jw] 26-Jan-2010
    var makePng = (function()
         // Table of CRCs of 8-bit messages
         var CRC_256 = [0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x1db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x6b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0xf00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x86d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x3b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x4db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0xd6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0xa00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x26d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x5005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0xcb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0xbdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
         // PNG Cyclic Redundancy Code algorithm -- http://www.w3.org/TR/PNG/#D-CRCAppendix
         var crc32s = function(/*uint[]*/buf)
              var c = 0xffffffff, i;
              for( i=0 ; i < buf.length; i++ )
                   c = CRC_256[(c ^ buf.charCodeAt(i)) & 0xff] ^ (c >>> 8);
              return (c ^ 0xffffffff);
         var header = function ()
              return "\x89PNG\x0D\x0A\x1A\x0A";
         var i2s = function (/*int32*/i)
              return String.fromCharCode(i>>>24) + String.fromCharCode(i>>>16) + String.fromCharCode(i>>>8) + String.fromCharCode(i);
         var chunk = function (/*4 Char PNG code*/chunkType, /*data*/data)
              var buf = chunkType + data;
              var crc = crc32s(buf);
              buf = i2s (data.length) + buf + i2s (crc);
              return buf;
         var adler32 = function (/*string*/buf)
              var i, a = 1, b = 0;
              for (i=0; i<buf.length; i++)
                   a += buf.charCodeAt(i); s1 %= 65521;
                   b += a; b %= 65521;
              return (b<<16)+a;
         return function(/*int*/wide, /*int*/high, /*string*/ pal, /*string*/image, /*string*/transpIndex)
              var t, bits;
              if (pal.length % 3)
                   alert ("Bad Palette length -- not a multiple of 3");
                   return null;
              if (image.length != high*wide)
                   alert ("Size error: expected "+(high*wide)+" bytes, got "+image.length);
                   return null;
              bits = '';
              for (t=0; t<high; t++)
                   bits += "\x00"+image.substr(t*wide, wide);
              t = bits.length;
              bits += i2s (adler32(bits));
              var r = header() + chunk ('IHDR', i2s (wide)+i2s(high)+"\x08\x03\x00\x00\x00");
              r += chunk ('PLTE', pal);
              if (transpIndex != null)
                   r += chunk ('tRNS', transpIndex);
              r += chunk ('IDAT', "\x78\x9c\x01"+ String.fromCharCode (t & 0xff)+String.fromCharCode((t>>>8) & 0xff)+String.fromCharCode ((~t) & 0xff)+String.fromCharCode(~(t>>>8) & 0xff)+bits);
              r += chunk ('IEND', '');
              return r;
    /* Sample usage. Remove when #including the above in _your_ script! */
    var pngPal  = "\x00\x00\x00"+"\xff\x00\x00"+"\x00\xff\x00"+"\x00\x00\xff"+"\xff\xff\x00"+"\x40\x40\x40";
    var pngData =     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"+
                        "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x00"+
                        "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x00"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05";
    img = makePng (10,11, pngPal, pngData, "\x40");
    var w = new Window("dialog", "Image test");
    w.add ('image', undefined, img);
    var f = new File(Folder.myDocuments+"/test-me2.png");
    if (f.open('w'))
         f.encoding = "BINARY";
         f.write (img);
         f.close();
    } else
         alert ("eh -- couldn't write test file...");
    w.show();

    Here is a more complicated (and useful ) example. (--Its actual usefulness is not as, erm, useful as I hoped, because it seems you don't have access to the built-in stroke styles! If anyone knows a work-around that, let me know ...)
    First, create a few custom Striped and/or Dashed stroke styles; then call this Javascript to see them created "live" in the drop down. Make sure you removed the sample code from the end of "pnglib.jsx", otherwise that dialog with interfere and mess up my nice program.
    #include "pnglib.jsx"
    function createStripeImg (styleIndex)
         var pngPal  = "\x00\x00\x00"+"\xff\xff\xff";
         var pngData = '';
         var x,y, ystart;
         var stripes = [];
         var i;
         for (y=0; y<app.activeDocument.stripedStrokeStyles[styleIndex].stripeArray.length; y++)
              stripes.push (Math.round (11*app.activeDocument.stripedStrokeStyles[styleIndex].stripeArray[y]/100));
         i = 0;
         for (y=0; y<11; y++)
              if (y >= stripes[i])
                   if (y <= stripes[i+1])
                        for (x=0; x<48; x++)
                             pngData += "\x00";
                        continue;
                   i += 2;
              for (x=0; x<48; x++)
                   pngData += "\x01";
         return makePng (48,11, pngPal, pngData, "\xff\x00");
    function createDashImg (styleIndex)
         var pngPal  = "\x00\x00\x00"+"\xff\xff\xff";
         var pngData = '';
         var x,y, xstart;
         var dashes = [];
         var i, len;
         len = 0;
         for (y=0; y<app.activeDocument.dashedStrokeStyles[styleIndex].dashArray.length; y++)
              len += app.activeDocument.dashedStrokeStyles[styleIndex].dashArray[y];
         xstart = 0;
         for (y=0; y<app.activeDocument.dashedStrokeStyles[styleIndex].dashArray.length; y++)
              dashes.push (xstart);
              xstart += Math.round (48*app.activeDocument.dashedStrokeStyles[styleIndex].dashArray[y]/len);
         dashes.push (47);
         i = 0;
         for (y=0; y<11; y++)
              if (y < 3 || y > 8)
                   for (x=0; x<48; x++)
                        pngData += "\x01";
              } else
                   xstart = 0;
                   for (x=0; x<48; x++)
                        if (x >= dashes[xstart])
                             if (x >= dashes[xstart+1])
                                  xstart += 2;
                             pngData += "\x00";
                        } else
                             pngData += "\x01";
         return makePng (48,11, pngPal, pngData, "\xff\x00");
    if (app.activeDocument.stripedStrokeStyles.length+app.activeDocument.dashedStrokeStyles.length < 1)
         alert ("This example needs a few custom stripe or dash stroke styles to play with");
         exit (0);
    var w = new Window("dialog", "Select a stripe type");
    var ddl = w.add("dropdownlist");
    for( i=0; i < app.activeDocument.stripedStrokeStyles.length; i++)
         (ddl.add('item', " "+app.activeDocument.stripedStrokeStyles[i].name)).image = createStripeImg (i);
    for( i=0; i < app.activeDocument.dashedStrokeStyles.length; i++)
         (ddl.add('item', " "+app.activeDocument.dashedStrokeStyles[i].name)).image = createDashImg (i);
    ddl.selection = 0;
    g = w.add ("group");
    g.orientation = 'row';
    g.add ("button", undefined, "OK");
    g.add ("button", undefined, "Cancel");
    w.show();

  • How to reference application version number and current date in page footer

    Am new to Apex and am creating first app for production users on Apex 4.0.1 ... I notice that Application Builder app itself displays the version number at bottom right of screen .. are there any substitution strings that I can use to get current date and application version in my own Apex app ... or do I need to create e.g Javascript to format the date and create my own substitution string ?
    Any help much appreciated .. thanks !

    I modified the Footer of our Default page template. Used JavaScript for the date, below is the code we use. The very last table is specific to our environment and it would need to be customized for your use or removed if not needed. I am a JavaScript novice so this may be crude but it does the job.
    Jeff
    <table width="100%" cellpadding="0" cellspacing="0"
    border="0">
    <tr>
    <td width="500">
    <script Language="JavaScript">
    <!--
    function GetDay(nDay)
         var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
                              "Thursday","Friday","Saturday");
         return Days[nDay]
    function GetMonth(nMonth)
         var Months = new Array("January","February","March","April","May","June",
                                "July","August","September","October","November","December");
         return Months[nMonth]             
    function GetTime () {
      var curtime = new Date();
      var curhour = curtime.getHours();
      var curmin = curtime.getMinutes();
      var cursec = curtime.getSeconds();
      var time = "";
      if(curhour == 0) curhour = 12;
      time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
             (curmin < 10 ? "0" : "") + curmin + ":" +
             (cursec < 10 ? "0" : "") + cursec + " " +
             (curhour > 12 ? "PM" : "AM");
      return time;
    function DateString()
         var Today = new Date();
         var suffix = "th";
         switch (Today.getDate())
              case 1:
              case 21:
              case 31:
                   suffix = "st"; break;
              case 2:
              case 22:
                   suffix = "nd"; break;
              case 3:
              case 23:
                   suffix = "rd"; break;
         var strDate = GetDay(Today.getDay()) + " - " + GetMonth(Today.getMonth()) + " " + Today.getDate(); strDate += suffix + ", " + Today.getFullYear() + " " ;
         return strDate
    //-->
    </script>
    <script Language="JavaScript">
    <!--
    document.write(DateString() + GetTime());
    //-->
    </script>
    </td>
    <td width="300" class="fineprint"><div align="right">
    </div></td>
    <td width="900" class="fineprint"><div align="right">
    &APP_USER.
    #APP_VERSION#
    </div></td>
    </tr>
    </table>
    <table width="100%" cellpadding="0" cellspacing="0"
    border="0">
    <tr>
    <td width="33%" align="left" valign="bottom"><img
    src="#WORKSPACE_IMAGES#iconseal-rust.gif" alt="NH State Seal" width="25"
    height="25" /></td>
    <td  width="33%" align="center" valign="bottom"><a href="http://www.nh.gov/" class="fineprint">NH.gov</a>
      <a href="http://www.nh.gov/disclaimer.html"
    class="fineprint">Privacy Policy</a>   <a
    href="http://www.nh.gov/wai/index.html" class="fineprint">Accessibility
    Policy</a></td>
    <td width="33%" class="fineprint"><div align="right">Copyright &#169 State of
    New Hampshire, 2007-2010</div></td>
    </tr>
    </table><br />
    #FORM_CLOSE#
    </body>
    </html>

Maybe you are looking for

  • Crystal Report 10 take toomuch time to display report

    hi every one i have designed some reports  with crystal report 10. i am using classic ASP and windows 2003 Enterprise server as web server. The problem is that when i browse the report in Internet explorer, it takes too much time to display the repor

  • File names trashed

    I am unfortunately still using version 6. However, I am hoping someone else has had this problem this is on a mac running Tiger 4.6. When I setup a site and put the files to a remote location, the files are all associated with textedit and the names

  • Copying data to multiple fields

    I have a number of forms which have been created in Acrobat 8 Professional using the Acrobat tools (not LiveCycle) where I need data entered in one field to copy to another. Usually this data is text. I have used the following Javascript in the Calcu

  • Help with "Tabbed panels"

    Hi guys, i am trying to design a web for my company. The company devided in to three parts. Every part has a slightly different menu. I assume i could use "tabbed panels" for that purpose but the contents of tabs are changed only on mouse click. I wo

  • Email folder view issue with netbook laptop

    Help!  Cannot see my email folders listed when I use my Samsung netbook.  Clicking on folders opens the folder list on the right side but there is nothing to click on on the left side.  The folder list is visible on the left side when I use a desktop