Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 23rd, 2005, 07:37 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp file into a javascript file (js)?

Could someone create this asp file into a javascript file (a .js file) and still have all of it's functionality?


<script type="text/javascript">
function SelectSize()
{
var dropDown=document.getElementById("size");
var SelectedSize = dropDown.options[dropDown.selectedIndex].value;
document.body.style.fontSize=SelectedSize + "px";
}
</script>
<form name="frmcontrol">
<select id=size onChange="SelectSize()" >
<option value="20">Default
<option value="12">Very Small
<option value="18">Smaller
<option value="26">Medium
<option value="36">Bigger
<option value="48">Larger
<option value="72">Very Large
</select>
<input type="button" value="Change Size of Text" name="myButton" onClick="SelectSize()" />
</form>

<script language="javascript">

function colorChange()
{
document.bgColor=document.list.colors.options[document.list.colors.selectedIndex].value;
}
</script>
<form name="list">
<select name="colors">
<option value="006633">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Background color" name="myButton2" onClick="colorChange()" />
</form>



<script language="javascript">

function change()
{
document.fgColor=document.text.color.options[document.text.color.selectedIndex].value;
}
</script>
<form name="text">
<select name="color">
<option value="black">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Text color" name="myButton3" onClick="change()" />
</form>
<p>Hello</p>


Reply With Quote
  #2 (permalink)  
Old August 24th, 2005, 04:44 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default



Hii jstewie !!!
  I think you want to use a single javascript file and include it in ur asp/html code
if this is the case then followinig will help you

1>put all javascript function in ur .js file
2>put ur js file in <head></head>


****myfile.js*****
function SelectSize()
{
var dropDown=document.getElementById("size");
var SelectedSize = dropDown.options[dropDown.selectedIndex].value;
document.body.style.fontSize=SelectedSize + "px";
}

function colorChange()
{
document.bgColor=document.list.colors.options[document.list.colors.selectedIndex].value;
}

function change()
{
document.fgColor=document.text.color.options[document.text.color.selectedIndex].value;
}
*****
Your original html/asp page will look like





<HTML>
<HEAD>
    <TITLE>test</TITLE>
    <SCRIPT SRC="myfile.js" LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
    </SCRIPT>
</HEAD>
<form name="frmcontrol">
<select id=size onChange="SelectSize()" >
<option value="20">Default
<option value="12">Very Small
<option value="18">Smaller
<option value="26">Medium
<option value="36">Bigger
<option value="48">Larger
<option value="72">Very Large
</select>
<input type="button" value="Change Size of Text" name="myButton" onClick="SelectSize()" />
</form>

<form name="list">
<select name="colors">
<option value="006633">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Background color" name="myButton2" onClick="colorChange()" />
</form>

<form name="text">
<select name="color">
<option value="black">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Text color" name="myButton3" onClick="change()" />
</form>
<p>Hello</p>

**********


Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old August 25th, 2005, 08:32 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks that is sort of what I was looking for. I did want a javascript file and you made that for me. Thank you for that. I just don't want to keep putting in the same code aka the forms in every asp file I make. I just want to create a link to the a file that has all the forms, just the same way as the <SCRIPT SRC="myfile.js" LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"> </SCRIPT> works. So, that way, the user can change the text and colors on all of my webpages (asp files). I have a javascript file and now I need a one file that has all three forms included in that one file. Is this possible? Please help me.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run a .js file from a javascript function sbkumar Javascript How-To 1 July 11th, 2008 11:12 AM
Execute Stored Procdure from Javascript(JS) file AbrarNazeer Javascript How-To 1 March 18th, 2008 06:39 AM
Using js file in ASP.NET ndr1977 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 26th, 2006 04:57 AM
convert a js file from a asp file - change format jstewie Javascript How-To 0 July 21st, 2005 08:57 AM



All times are GMT -4. The time now is 06:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.