Auto-fill table cells in a selection

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Auto-fill table cells in a selection

    Hello,

    I'm fairly new to Dreamweaver, but I have an unusual problem, and would be
    glad for some help.

    I'm placing online an ancient piece of literature which, in the original is
    laid out in tabular form. It's actually a chronicle, and has vertical columns
    the number of years kings in different kingdoms have reigned, with notes of
    things that happened that year against them. So:

    |Romans | Greeks
    |1 | 23 Eclipse of the sun.
    |2 | 24 First battle of the Romans against the
    Greeks.
    |3 | 25

    There are endless columns of these, and endless pages. I'm getting tired of
    entering all these numbers.

    What I would like to do is type a number in the top cell (e.g. 23 in the
    above), select the next two cells in the column 'Greeks', and run a command
    which will take the entry in the first cell (first selected cell?) and populate
    the others with 24, 25, ... (adding one each time).

    I hope this makes sense -- it's a devil to explain but obvious when you're
    doing it.

    Can anyone tell me how to write a command or macro to do this? I feel that it
    must be possible -- just that my DW command-writing skills don't go very far
    just yet.

    One caveat -- the last person I asked suggested either that I use Excel and
    import it, or use an OL tag. Neither is feasible for what I wish to do. It
    does need to be something like 'select a set of cells in a
    column, enter a number n in the first cell, press a key and the other cells
    get filled with n+1, n+2, etc.'

    Many thanks,

    Roger Pearse


    Roger_Pearse Guest

  2. Similar Questions and Discussions

    1. Auto fill email address
      I've create a "e-mail back" button on a PDF form so that by clicking on the button, it will launch the default email program on their computer. My...
    2. Do not want Auto Fill Forms
      I'm creating a form field in an already created pdf document. The form is for 5 people to sign there initials, type in the date, and hit a radio...
    3. Howto loop through table cells in a selection
      Hello, I'm new to DW development, so I wonder if someone could help me. Say my user selects a few cells in a column in a table, and then runs my...
    4. auto fill form
      <%@LANGUAGE='JAVASCRIPT' CODEPAGE='1252'%> SELECT distinct , make, , FROM ndcinventory ORDER BY model I have a form with drop down selection...
    5. How to fill in a selection, please
      When I use the selection paintbrush to draw an outline around the perimeter of an object (e.g. the outside edge of the head of a person), is there an...
  3. #2

    Default Re: Auto-fill table cells in a selection

    Create an Access database and do it in that. Set the first two columns as
    autonumber

    Bill


    BillB Guest

  4. #3

    Default Re: Auto-fill table cells in a selection

    For anyone else who wants to know, the answer was:

    [email]roger_pearse@yahoo.co.uk[/email] wrote in message news:<1111156512.453612.137340@o13g2000cwo.googleg roups.com>...
    > danilocelic *TMM* wrote:
    > > Roger_Pearse wrote:
    > > > Hello,
    > > >
    > > > I'm new to DW development, so I wonder if someone could
    > > > help me. Say my user selects a few cells in a column in
    > > > a table, and then runs my command. How can I loop
    > > > through the cells in the selection, so that I can read and
    > > > write the text in each cell?
    > > >
    > > > I realise this is probably trivial if you know your way
    > > > around the object model, but I don't, as yet.
    > >
    > > Try something like the following:
    > > var dom = dw.getDocumentDOM()
    > > // grab multiple selections, which corespond to pair's of offsets
    > > var sel = dom.getSelection(true);
    > >
    > > var objs = new Array();
    > >
    > > for(var i=0;i<sel.length;i+=2){
    > > // take current selection pair and convert to a tag
    > > // and stuff into an array to play with
    > > objs.push(dom.offsetsToNode(sel[i],sel[i+1]));
    > > }
    > >
    > > // set inertHTML of first node
    > > objs[0].innerHTML='hello'
    >
    > Many thanks indeed -- I'll experiment.
    Final solution: a file called Chronicon.htm in the c:\program
    files\macromedia\dreamweaver mx\configuration\commands folder.
    Contents:

    ----start of file--
    <html>
    <script language=Javascript>

    //-----------------------------

    function populateCells() {

    var dom = dw.getDocumentDOM()

    // grab multiple selections, which corespond to pair's of offsets
    var sel = dom.getSelection(true);

    var objs = new Array();

    //alert(sel.length/2); //--No of table cells selected

    for(var i=0;i<sel.length;i+=2){
    // take current selection pair and convert to a tag
    // and stuff into an array to play with
    objs.push(dom.offsetsToNode(sel[i],sel[i+1]));
    }

    // Value in first cell. Must subtract zero to force string to
    // numeric.
    var startValue = objs[0].innerHTML - 0;
    if (startValue == 0) {
    alert("First value in selection must contain a numeric");
    return;
    }

    //-- Populate all cells
    for(var i=0;i<sel.length/2;i++){
    // set inertHTML of first node
    objs[i].innerHTML= i + startValue;
    }

    } //--End of populateCells
    //------------------------------

    </script>
    <body OnLoad=populateCells()>
    </body>
    </html>
    ----end of file---

    Many thanks indeed!

    All the best,

    Roger Pearse
    Roger Pearse Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139