Hey guys I need some javascript function + action scripts.
Can anyone give me the print the window script, I also need the clear the textarea script, the highlight text script, and the browse and open file script. I am looking for something along the lines of:
-------------------------------------------------------------->
function save()
{
str = document.forms[0].text_area.value;
mydoc = document.open();
mydoc.write(str);
mydoc.execCommand("saveAs",true,".txt");
mydoc.close();
}
----------------------------------------------------------------->
Except of course for Clearing the textarea, printing the window, highlighting the text within the textarea, and the browse/open file scripts.
PLease someone help me out I have three javascript books and Ive been scouring the net, and still nothing . . .
I really need some help, (not just mentally this time).
Alright guys thats the mission, now make me proud, jk..lol
be cool guys,
Code One
Code One
03-09-2003, 04:59 PM
Thanks alot!!!!
be cool
Code One
Code One
03-09-2003, 05:07 PM
I was kinda hoping I would get the scripts to do this:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var button = new Array();
var action = new Array();
var buttonWidth = new Array();
button[1] = '<u>S</u>ave';
buttonWidth[1] = 50; //This is the button's width, in pixels.
action[1] = function save()
{
str = document.forms[0].text_area.value;
mydoc = document.open();
mydoc.write(str);
mydoc.execCommand("saveAs",true,".txt");
mydoc.close();
}
button[2] = '<u>C</u>lear';
buttonWidth[2] = 50; //This is the button's width, in pixels.
action[2] = function reset() {
//I need this script
}
button[3] = '<u>O</u>pen';
buttonWidth[3] = 50; //This is the button's width, in pixels.
action[3] = function FolderChoose() {
//I need this script
}
button[4] = '<u>P</u>rint';
buttonWidth[4] = 50; //This is the button's width, in pixels.
action[4] = function window.print() {
//I need this script
}
button[5] = 'C<u>l</u>ear';
buttonWidth[5] = 50; //This is the button's width, in pixels.
action[5] = function reset() {
//I need this script
}
button[6] = 'Cop<u>y</u> ';
buttonWidth[5] = 50; //This is the button's width, in pixels.
action[6] = function () {
//I need this script
}
///////////////////////////////////////////////////////////////////////////
/////////////////////// END OF EDITABLE SECTION ///////////////////////////
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Don't edit bellow or you could get errors! //
////////////////////////////////////////////////////////////////////////////
function placeButton(value) {
if (button[value]) {
if (button[value].indexOf('<u>') != -1) {
document.write('<button id="b'+value+'" style="Width : '+buttonWidth[value]+'px ; Height : 22px" onClick="action['+value+']()"><font face="MS Sans Serif" size="1">'+button[value]+'</button>');
} else {
alert('You didn\'t specify the underlined letter for the button number '+value+'. This button cannot be placed until you specify the underlined letter by using <u> and </u> tags.');
}
} else {
alert('You are trying to place the button number '+value+', but you didn\'t declare its values on the variables area. \r\rThe button '+value+' will not be placed until you specify the variables "button['+value+']" and "action['+value+']".');
}
}
</HEAD>
<BODY>
<script>placeButton(1)</script>
<script>placeButton(2)</script>
<script>placeButton(3)</script>
<script>placeButton(4)</script>
<script>placeButton(5)</script>
<script>placeButton(6)</script>
<form>
<textarea name="text_area" rows="14" cols="40"></textarea> <!--please asscoiate the scripts with this textarea-->
</form>
(As you can see I have the save button working but I dont know the scripts to make the print, highlight text, clear text area, or open/browse buttons to work in association with the textarea.) Can anyone please add the scripts to this code to associate the buttons with the textarea? I would truly appreciate it.
Code One
Code One
03-09-2003, 05:25 PM
yeah I guess your right. . . Im just getting tired and lazy, I would rather learn it on my own, but I cant find that info anywere so I figured I would have someone who does it every day add what I dont already have. I figured it would be a matter of 5 -6 lines long for each, but your rigt I shouldnt expect anyone to hold my hand, so thanks just the same and I will tred forward to your links and bash my head into a wall.
Thanks
Code One
Code One
03-09-2003, 05:45 PM
yes khalid is a fine programmer always willing to help. I have actually recieved alot of help from khalid, slao pyro, now thers another good guy, jona too though he seems to always be wrong or uninformative, still he trys and that is what counts, plus I too try to offer what little help I can, for instance once I have a working code I will then post here, so that anyone can swipe it and use it in there work, I like to do that I figured if someone comes to a forum it is because they cannot find the answer out there in cyber space, so they drag themselves to a forum and ask how do I do this? Some times no one knows, or if they do they provide only small syntax not including a working module, which is no way for a newbie to learn, so I figure how bout get a working module post it here and anyone who comes along looking for the same solution can automatically obtain the solution, with out staying up till 8 in the morning popping zolof, to feel happy, and drinking alchol to pretend its ok. I am what you call a giver and a taker, the leader of ALL newbies, in the world of web development. lol
stay cool yall
Code One
p.s. for you newbie coders dont worry once I figure this one out I will be sure to post the results . . this code will provide you with windows typee buttons, YES you can now have buttons just like your windows application. You know the ones that say File or Tools, etc. and have a line under a specific letter. Cool right, not only that you can assing an altkey function to them making it easier to select your buttons, just like in your windows apps!!!!! woo hooo right, well trust be its alot cooler than you think. check back here in a week or so for the answer.
CO
khalidali63
03-09-2003, 06:19 PM
Thanks..
Try thi link and let me know if this is anything closer to what you wanted or its even farther then the solution..lol.
I assume you know that this will work in IE only( 100%)
Hey, Khalid, it didn't seem to work to open a file... I'm using IE 6, and I was trying to open a .txt file... Did it work for you??
pyro
03-09-2003, 06:41 PM
This seems pretty close to what you need:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var button = new Array();
var action = new Array();
var buttonWidth = new Array();
button[1] = '<u>S</u>ave';
buttonWidth[1] = 50; //This is the button's width, in pixels.
action[1] = function save()
{
str = document.forms[0].text_area.value;
mydoc = document.open();
mydoc.write(str);
mydoc.execCommand("saveAs",true,".txt");
mydoc.close();
}
button[2] = '<u>C</u>lear';
buttonWidth[2] = 50; //This is the button's width, in pixels.
action[2] = function reset() {
document.myform.text_area.value = "";
}
button[3] = '<u>O</u>pen';
buttonWidth[3] = 50; //This is the button's width, in pixels.
action[3] = function FolderChoose() {
document.execCommand("Open",true,".txt");
}
button[4] = '<u>P</u>rint';
buttonWidth[4] = 50; //This is the button's width, in pixels.
action[4] = function printpage() {
window.print();
}
button[5] = '<u>H</u>ighlight';
buttonWidth[5] = 50; //This is the button's width, in pixels.
action[5] = function hightlight() {
document.myform.text_area.select();
}
button[6] = 'Cop<u>y</u> ';
buttonWidth[5] = 50; //This is the button's width, in pixels.
action[6] = function copythis() {
document.execCommand("Copy");
}
///////////////////////////////////////////////////////////////////////////
/////////////////////// END OF EDITABLE SECTION ///////////////////////////
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Don't edit bellow or you could get errors! //
////////////////////////////////////////////////////////////////////////////
function placeButton(value) {
if (button[value]) {
if (button[value].indexOf('<u>') != -1) {
document.write('<button id="b'+value+'" style="Width : '+buttonWidth[value]+'px ; Height : 22px" onClick="action['+value+']()"><font face="MS Sans Serif" size="1">'+button[value]+'</button>');
} else {
alert("You didn't specify the underlined letter for the button number "+value+". This button cannot be placed until you specify the underlined letter by using <u> and </u> tags.");
}
} else {
alert("You are trying to place the button number "+value+
", but you didn't declare its values on the variables area. \r\rThe button "+value+
" will not be placed until you specify the variables button["+value+"] and action["+value+"].");
}
}
</HEAD>
<BODY>
<script>placeButton(1)</script>
<script>placeButton(2)</script>
<script>placeButton(3)</script>
<script>placeButton(4)</script>
<script>placeButton(5)</script>
<script>placeButton(6)</script>
<form name="myform">
<textarea name="text_area" id="text_area_id" rows="14" cols="40"></textarea> <!--please asscoiate the scripts with this textarea-->
</form>
</body>
</html>
Code One
03-09-2003, 09:38 PM
Thank you PYRO, thank you Khalid . . . you guys are some really cool people!!!!! You are always offering more than you have to, to anyone who asks, you descriminate noone, and for that I give you my complete and utter respect for you both. You guys deserve much more than I can give you, not just for helping me with codes and stuff but for just being unlike alot of seasoned programmers. You seem to careless about making money, and more about just being nice and ensightful. Im glad you guys use this forum as a medium to teach and thats why I keep coming back to this forum everytime I need a bug fix. I know I can count on you all to help out when you can. Welp thanks alot, and never change (...edited...)
Im out
Code One
Newbie Note:* I am like 2 secs from being done with this code, (exscuse my illetiracy) . . . so like I told you above, I will with out a doubt provide to you the WHOLE working code, notice that if you copy and paste pyros code it wont work, thats because I left out alot of the code. So hang tight and I will post the full thing, in just a bit. Cool?
CO
Edit: Sorry guys I just realized something else, you could just go to Khalids link and viewsource and copy his code, he went ahead and added the rest of the code I left out, (see what I mean, always going above and beyond), However, If you are so new and you have no idea what the heck Im talking about(viewsource code), then, I will still post the full code for you, but under another thread.
CO
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.