Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a generator question

    Hello,

    I want to make myself a tool where if I paste in multiple lines of text cells (most likely from Excel, but that shouldn't matter), it will generate the pre-file extension and the ending file extension and echo it back on the page (not saving or storing, just temporary).

    I have no trouble creating a form in javascript (or php) that could input the extension automatically for 1 item, but I was wondering if it's possible for a list of multiples within the same form box?

    For example, I want to copy and paste this set of assets from excel into my form box:
    asset1
    asset2
    asset3
    asset4
    asset5
    asset6
    asset7


    Submit it and receive an echo on the page of this. The stuff in bold will always be the same, just wrapped around the asset i inputted into the form.
    /f1/blah/example/asset1.xml
    /f1/blah/example/asset2.xml
    /f1/blah/example/asset3.xml
    /f1/blah/example/asset4.xml
    /f1/blah/example/asset5.xml
    /f1/blah/example/asset6.xml
    /f1/blah/example/asset7.xml

    I was able to create the form for 1 item, but not multiple.
    I just started to learn... so please don't be mad or flame me!! I am just wondering how difficult it is to learn to make this.

    Thanks!

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Posts
    462
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Code:
    array = []
    array = forminput.split('\n\r'); 
    // depending on how it's placed in the form element.
    // could also be  \r\n, \n still depends.
    
    
    var pre = '/f1/blah/example/';
    var suf = '.xml';
    var Output = '';
    
    for ( var i=0; i<array.length; i++){ Output += pre + array[i] + suf + '<br>'; }
    
    document.write(Output);
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    For projects using MediaTypes (MIMETypes) visit E-BAM.net -(updated weekly)

    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Ill try it.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Ummm...no. Not quite.

    peabody wrote "I want to copy and paste this set of assets from excel into my form box."

    So he can't then use document.write without wiping out the entire page.

    How about thie:
    Code:
    <html>
    <body>
    <form>
    <textarea name="box" rows="20" cols="80"></textare>
    <br/>
    <input type="button" value="DO IT!"
     onclick="this.form.box.value = 
             '/f1/blah/example/' + this.form.box.value.replace(/\n/g,'.xml\n/f1/blah/example/') + '.xml';"
    />
    </form>
    </body>
    </html>
    Try it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! But I'm not a HE hahhaa. I'm a she!!

    Anyway, I will try it right now! Thank you.

  • #6
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It worked great!
    Any chance I can make it so the paths show up NOT inside the box? Maybe below it?

    I have a javascript manual / html handbook, so I'll check it.

    Either way, it worked fine. Thank you!

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Code:
    <html>
    <body>
    <form>
    <textarea name="box" rows="20" cols="80"></textare>
    <br/>
    <input type="button" value="DO IT!"
     onclick="document.getElementById('putItHere').innerHTML = 
             '/f1/blah/example/' + this.form.box.value.replace(/\n/g,'.xml\n/f1/blah/example/') + '.xml';"
    />
    
    Many lines of junk perhaps?
    Many lines of junk perhaps?
    Many lines of junk perhaps?
    Many lines of junk perhaps?
    
    <div id="putItHere"></div>
    
    </form>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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