Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th February 2005, 10:18 AM   #1
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default Javascript help

Hi guys ive been have troubles for a while on this javascript that ive created it works perfectly fine on ie but i can't get it to work on any other browser.


Heres the code.

Code:
function disableAreas() { cat = document.getElementById("cat").value; desc = document.getElementById("desc"); banner = document.getElementById("bannerurl"); webname = document.getElementById("webname"); if(cat == "1" || cat == "3" || cat == "4") { desc.disabled = true; desc.value = "Disabled"; } else { desc.disabled = false; desc.value = ""; } if(cat == "2" || cat == "4") { banner.disabled = true; banner.value = "Disabled"; } else { banner.disabled = false; banner.value = ""; } if(cat == "1" || cat == "3") { webname.disabled = true; webname.value = "Disabled"; } else { webname.disabled = false; webname.value = ""; } if(cat == "1" || cat == "2" || cat == "4") { for(i = 0; i < 5; i++) { document.submit_banner.bannersize[0].disabled = true; document.submit_banner.bannersize[1].disabled = true; document.submit_banner.bannersize[2].disabled = true; } } else { for(i = 0; i < 5; i++) { document.submit_banner.bannersize[0].disabled = false; document.submit_banner.bannersize[1].disabled = false; document.submit_banner.bannersize[2].disabled = false; } } }

let me try to explain what this code does.
What it does is it disables certain form fields like textareas input buttons and such on a form depending what you selected in a dropdown box.

like i said it works fine in ie but not in any other browser. im just learning javascript im still surprised i got this to work on ie lol.

Any help is appreciated.

Thanks

Viper
__________________
viper is offline   Reply With Quote
Old 28th February 2005, 10:31 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Congrats. I probably could'nt have doen that. I'm also not a JavaScripter...

I've got a mate who might be able to help you... I'll try get you an answer today

Tech
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 28th February 2005, 10:40 AM   #3
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

Thanks ben theres no big rush on this since it does work on one browser lol. I'm more of a php guy my self too but it's always good to know javascript too i guess for webdesign, That's why im trying to learn it lol it's going alot slower than whey i learnt php lol.

Thanks again

Viper
__________________
viper is offline   Reply With Quote
Old 28th February 2005, 09:18 PM   #4
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

he needs the HTML form code
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 2nd March 2005, 09:11 AM   #5
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

thanks ben heres the code for the html form

Code:
<form method="post" action="add_ad.php" onSubmit="return disableForm(this);" name="submit_banner"> Website Name: <input type="text" name="webname" id="webname"> Website URL: <input type="text" name="weburl" id="weburl"> Email Address: <input type="text" name="email" id="email"> Payment Option: <select name="payment"><option value="1m">1 Month</option><option value="2m">2 Months</option><option value="3m">3 months</option></select> Advertising Option: <select name="cat" onChange="disableAreas()"> <option value="">--Select Option--</option> <option value="1">Top of page advertising</option> <option value="2">Sidebar Advertising</option> <option value="3">Button Advertising</option> <option value="4">Sidebar (titleonly)</option> </select> Banner URL: <input type="text" name="bannerurl" id="bannerurl"> Banner Size: <input type="radio" name="bannersize" id="bannersize" value="88x31" checked="checked">88x31 <input type="radio" name="bannersize" id="bannersize" value="120x90">120x90 <input type="radio" name="bannersize" id="bannersize" value="125x125">125x125 Description: <textarea name="desc" id="desc" cols="35" rows="6" maxlength="30"></textarea> <input type="submit" name="submit" value="Join" class="mainoption" onClick="return checksubmit(this)"> </form>

i stripped off the html table in the form to make it easier to read on the forums.
__________________

Last edited by viper : 2nd March 2005 at 09:17 AM.
viper is offline   Reply With Quote
Old 2nd March 2005, 09:26 AM   #6
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Thanks Viper... I've sent the html off to myf riend for checking...

I actually found some other code while searching that may work for you... I'll try get it working for your original code but this might be helpful:

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Form enabler/disabler</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> ElemID = new Array() ElemID[0] = ["q","qw","qwe"] ElemID[1] = ["q","a"] flag = false function disableFrm(ElemIDGroup) { flag = !flag for (i=0; i<ElemID.length; i++) { for (j=0; j<ElemID[ElemIDGroup].length; j++) { document.getElementById(ElemID[ElemIDGroup][j]).disabled = flag } } } </script> </head> <body> <select id="ElemIDGroup"> <option value="0">Group 1</option> <option value="1">Group 2</option> </select> <input type="button" value="disable/enable form" onclick="disableFrm(document.getElementById('ElemIDGroup').value)" /><br /> <form method="get" action="file.php"> name: <input type="text" id="q" /><br /> <textarea id="qw"></textarea><br /> <input type="button" id="qwe" value="random button" onclick="alert('hello')" /><br /> <select id="a"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> <option value="d">d</option> </select> <input type="submit" /><input type="reset" /> </form> </body> </html>

Example of an alternative to the other solution:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <script language="JavaScript" type="text/javascript"> <!-- function lock(obj){ obj=document.getElementById(obj); if (obj.getAttribute('disabled')){ obj.removeAttribute('disabled'); } else { obj.setAttribute('disabled','disabled'); } } //--> </script></head> <body> <select id="fred" size="1" disabled="disabled" > <option>jan <option>feb <option>march </select> <input type="checkbox" checked=true name="" onclick="javascript:lock('fred');" > </body>

Hope the helps... I will see if I can get code for your html... Let me know if this works though
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote JavaScript Problems... Mr. Tech Webmaster Help 3 27th January 2005 11:22 AM
PHP: How To Hide Your JavaScript With PHP! Mr. Tech Tutorials 2 24th January 2005 08:15 AM
Help with a JavaScript please! New webmaster in need of hlp snitz427 Website Design & Coding 0 7th May 2004 04:21 AM
JavaScript question by razahasnain Mr. Tech Website Design & Coding 0 1st January 2004 10:40 AM
Hiding Your JavaScript!!!! Mr. Tech Website Design & Coding 1 25th September 2003 08:02 AM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 06:08 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore