hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Java Script help
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Java Script help

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-12-2003, 02:20 PM
ThermoDust ThermoDust is offline
WHT Addict
 
Join Date: Oct 2002
Location: IL
Posts: 100

Java Script help


I was making a java script to disable text and pull down menu on click depending on another here i the code

PHP Code:
<script language="JavaScript">
function 
disablecheck (field1,field2) {
  if(
window.document.field1.disabled=true && window.document.field2.disabled=false){
    
window.document.field1.disabled=false;
    
window.document.field2.disabled=true;
  }else if(
window.document.field1.disabled=false && window.document.field2.disabled=true){
    
window.document.field1.disabled=true;
    
window.document.field2.disabled=false;
  }
}
</script> 

Reply With Quote


Sponsored Links
  #2  
Old 02-12-2003, 02:28 PM
jonasf jonasf is offline
Junior Guru Wannabe
 
Join Date: Jan 2003
Posts: 82
hmm, ok, and your problem?
What doesn't work, or how do you use it later on?

Reply With Quote
  #3  
Old 02-12-2003, 02:47 PM
ThermoDust ThermoDust is offline
WHT Addict
 
Join Date: Oct 2002
Location: IL
Posts: 100
I use it on a check box:

Quote:
<input name="LPQ_OS" onClick"disablecheck(LPQ_O, LPQ_OS)" type="checkbox" id="LPQ_OS" value="1">
On click it should run that script that "should" disable a drop down menu and then enable a text box. But it doesnt do either

Reply With Quote
Sponsored Links
  #4  
Old 02-18-2003, 04:43 AM
postcore postcore is offline
Newbie
 
Join Date: Jan 2003
Posts: 16
Hmm.. You may have a problem with your field names.

This looked interesting to me so worked something up for this function.

Enjoy!
PHP Code:
<script language="JavaScript1.2">
function 
disable(r){
var 
frm document.myform
var 
condition = new Array();
var 
results   = new Array();
// set conditions needed to disable form elements ( as many as needed )
condition[0]  = "frm.field1.checked && frm.field2.checked"
condition[1]  = "frm.field2.checked && frm.field3.checked";
condition[2]  = "frm.field3.checked && frm.text3.value == 'lock'"// a little different ex.

results[0]    = "select1,text1";      // items to disable based on condition[0]
results[1]    = "text2,field1"// items to disable based on condition[1]
results[2]    = "text1,text3,select1"// items to disable based on condition[2]

for (var i=0i<condition.lengthi++)
if(eval(
condition[i])) var i// locate the first condition that returns true

    
for (var i=0i<frm.elements.lengthi++) { // loop through the form elements  
    
frm.elements[i].disabled false // reset all
      
if(!= null && eval(condition[k]) && !r){ 
      
disable_fields results[k].split(","); // find elements to disable
        
for (var j=0j<disable_fields.lengthj++) 
        if(
frm.elements[i].name == disable_fields[j]) frm.elements[i].disabled true    
      
** 
    **  
**
</script>
<form name=myform action="/" method="post">
<select name=select1>
<option value=1>opt 1
<option value=2>opt 2</select> select <br>
<input type=text name=text1 value=textbox1> text1<br>
<input type=text name=text2 value=textbox2> text2<br>
<input type=text name=text3 value=textbox3 onkeyup="disable()"> text3<br>
<input type=checkbox name=field1 value=1 onclick="disable()"> field 1<br>
<input type=checkbox name=field2 value=1 onclick="disable()"> field 2<br>
<input type=checkbox name=field3 value=1 onclick="disable()"> field 3<br>
<a href=# onClick="disable('reset')">enable all</a>
</form> 
<edit> Just a note, but the disable attribute is not available in NS 4.xx. Most other browsers support it though!


Last edited by postcore; 02-18-2003 at 04:48 AM.
Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Jelastic Integrates Java and PHP Cloud Platform with NetBeans IDE Web Hosting News 2013-05-06 13:34:29
Jelastic Releases Plugin for Java Development Environment IntelliJ IDEA Web Hosting News 2012-12-05 11:15:46
Jelastic Java Cloud App Deployment Gets Easier with Eclipse Partnership Web Hosting News 2012-12-17 13:50:32
Jelastic Java PaaS Service Now Enables App Building in the Cloud Web Hosting News 2011-11-18 16:57:16
Java Cloud Platform Jelastic Opens US Operations in Palo Alto, California Web Hosting News 2011-11-07 18:12:18


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?