#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    12
    Rep Power
    0

    Question What about Javascript Questions


    Hi All,
    I dont know if I should post my question here or not but, since every other language is discussed I wanted to know if we can ask Javascript questions...

    I have a good question!



    I might as well submit my question just in case

    I have been working on this BIG form, and I need to know if I can use a Loop to assing values ... etc


    /****************************************************
    This is original working form which recursively strips out values
    from a file field and gets the file name, next it stores the values to
    another form
    **************************************************/

    function doUpdateSubmit()
    {

    var _fullPath1 = document.frmFiles.FILE1.value;
    var _fullPath2 = document.frmFiles.FILE2.value;
    var _fullPath3 = document.frmFiles.FILE3.value;
    var _fullPath4 = document.frmFiles.FILE4.value;
    var _fullPath5 = document.frmFiles.FILE5.value;
    var _fullPath6 = document.frmFiles.FILE6.value;
    var _fullPath7 = document.frmFiles.FILE7.value;
    var _fullPath8 = document.frmFiles.FILE8.value;

    var _new_filename1 = _fullPath1.lastIndexOf("\\");
    var _fileName1 = _fullPath1.substring( _new_filename1+1, _fullPath1.length);

    var _new_filename2 = _fullPath2.lastIndexOf("\\");
    var _fileName2 = _fullPath2.substring( _new_filename2+1, _fullPath2.length);

    var _new_filename3 = _fullPath3.lastIndexOf("\\");
    var _fileName3 = _fullPath3.substring( _new_filename3+1, _fullPath3.length);

    var _new_filename4 = _fullPath4.lastIndexOf("\\");
    var _fileName4 = _fullPath4.substring( _new_filename4+1, _fullPath4.length);

    var _new_filename5 = _fullPath5.lastIndexOf("\\");
    var _fileName5 = _fullPath5.substring( _new_filename5+1, _fullPath5.length);

    var _new_filename6 = _fullPath6.lastIndexOf("\\");
    var _fileName6 = _fullPath6.substring( _new_filename6+1, _fullPath6.length);

    var _new_filename7 = _fullPath7.lastIndexOf("\\");
    var _fileName7 = _fullPath7.substring( _new_filename7+1, _fullPath7.length);

    var _new_filename8 = _fullPath8.lastIndexOf("\\");
    var _fileName8 = _fullPath8.substring( _new_filename8+1, _fullPath8.length);

    //Assign values to Allot of stuff for submittion to database
    document.frmUpdateAll.itemimage1.value = _fileName1;
    document.frmUpdateAll.itemimage2.value = _fileName2;
    document.frmUpdateAll.itemimage3.value = _fileName3;
    document.frmUpdateAll.itemimage4.value = _fileName4;
    document.frmUpdateAll.itemimage5.value = _fileName5;
    document.frmUpdateAll.itemimage6.value = _fileName6;
    document.frmUpdateAll.productFile.value = _fileName7;
    document.frmUpdateAll.prodImage.value = _fileName8;

    }

    I want to change it to something like this..... I may not be using the correct method to do this....

    /*********************************************
    This is not working
    *********************************************/

    function dothis()
    {

    var _usrID = document.frmAdd.usrID.value;

    var FILE = new Array("FILE1","FILE2","FILE3","FILE4","FILE5","FILE6");
    var image = new Array();
    var _fileName = new Array();
    var _fullPath = new Array();
    var _new_filename = new Array();
    var a=0;

    for (var i=1; i<6; i++)

    {
    /************* Just some tests
    alert ( i );
    alert (FILE[a]);
    var dod = FILE[a];
    var aa = "document.frmAdd.";
    var bb = ".value";
    var cc = "document.frmData.";
    var test = aa+FILE[a]+bb;
    alert (test);
    ********************/

    alert (a);
    _fullPath[a] = document.frmAdd.FILE[a].value;

    alert (_fullPath[a]);

    //Stripping filename
    _new_filename[a] = _fullPath[a].lastIndexOf("\\");
    _fileName[a] = _fullPath[a].substring( _new_filename[a]+1, _fullPath[a].length);

    alert (_fileName[a]);

    //Assign values to Allot of stuff for submittion to database

    document.frmData.image[a].value = _fileName[a];

    a++
    }


    I am submitting these two forms to two different places, the original form uploads the files using CGI script and once I have the filenames using this function I assign those file names to another form and submit that to write to the database.

    Any Help in this is appreciated.... This would be a learning curve for me...
    Last edited by ziggyz; July 3rd, 2003 at 08:21 PM.
  2. #2
  3. Thanks Johnny Hart (BC) R.I.P.

    Join Date
    May 2003
    Location
    Dallas
    Posts
    5,268
    Rep Power
    1956
    Move down the forum list to client side fora. There you will find the CSS, Javascript forum

    Cheers,

    gary
    There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

    My html and css workshop, demos and tutorials.
    Ask a better question, get a better answer.

IMN logo majestic logo threadwatch logo seochat tools logo