Forum Moderators: open

Message Too Old, No Replies

fill in the fields on a form from Excel doc from URL

javascript form URL

         

darinjohnson64

3:47 pm on May 25, 2004 (gmt 0)

10+ Year Member



I am having a brain cloud. I am new to Java.

I wrote a function to fill in the text fields of an online form from an Excel sheet:

javascript:function%20autofill()
{var r=1,j ; var F= document.contactadd; var XA = new ActiveXObject("Excel.Application");
if (XA!= null) {XA.Visible = true; XA.Workbooks.Open("C:/files/leads2.xls");
var XB = XA.Workbooks(1).Worksheets(1);
if(r=window.prompt('row #: ','') = null) r=1;
E= document.forms [0].elements;
// doc form [0] elements.length =24
E [1].selectedIndex = 0;
E [2]. checked=true ;
E [3].selectedIndex = 0;
E [4].selectedIndex = 0;
E [5].selectedIndex = 0;
for(j=4;j< E.length;j++) // skip non text fields
{if(j==5¦¦j==7¦¦j==10¦¦j==16 ¦¦ j==17¦¦ j==19¦¦ j==22) continue;
if (XB.Cells(r,j).Value!=null) document.forms [0].elements [j].value = XB.Cells(r,j).Value;
}}}autofill();void(null)

The problem is and it is a complete bonehead manueuver on my part, I have forgotten how to execute this function from the URL address box of my browzer. argh!

Please assist. Thanx

MichaelBluejay

7:17 pm on May 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



First of all, I think you mean you're new to JavaScript, not Java. JavaScript is a *completely* separate language from Java. It's clear from your post what you mean but if you go around saying Java when you mean JavaScript then someday someone will take you at your word and there will be some confusion.

To answer your question, to get a JavaScript function to execute directly from the address bar in a browser, type:

javascript:functionname()

I don't know why you wouldn't just make a link or button you could just click, though:

<A href="#" onclick="functionname()">

Hope this helps.

darinjohnson64

8:07 pm on May 25, 2004 (gmt 0)

10+ Year Member



yes, javascript.

I don't own the page that contains the form, so manipulating the form via URL was the most straight-forward method to accomplish my task.

It has been a rough week and your assistance is greatly appreciated.