...

View Full Version : Creating a generator question



peabody44
03-24-2012, 04:17 PM
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!

c1lonewolf
03-24-2012, 05:25 PM
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);

peabody44
03-24-2012, 06:11 PM
Thanks! Ill try it.

Old Pedant
03-25-2012, 05:49 AM
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:


<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.

peabody44
03-31-2012, 12:50 AM
Thanks! But I'm not a HE hahhaa. I'm a she!! :)

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

peabody44
03-31-2012, 12:54 AM
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!

Old Pedant
03-31-2012, 02:13 AM
<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum