LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2006, 07:56 PM   #1
intramaweb
LQ Newbie
 
Registered: May 2006
Location: Coventry, UK
Distribution: CentOS 5
Posts: 15

Rep: Reputation: 0
Javscript on-click not working


I've written the following code to trigger when the button with the ID "usrsubmit" it clicked. It doesn't seen to be working, however.

Code:
function usernamef() {
	var usrName = document.getElementById('username');
	usrSubmit = document.getElementById('usrsubmit');
	usrSubmit.onclick = function() {
		if(usrName.value == "") {
			alert('You must select your name before continuing.');
		} else {
			pOff('p1');
			pOn('p2');
		}
	}
}

window.onload = usernamef();
Any ideas anyone?
 
Old 10-30-2006, 01:21 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I would do :
Code:
function usernamef() {
    var usrName = document.getElementById('username');
    usrSubmit = document.getElementById('usrsubmit');
    
    if(usrName.value == "") {  
        usrSubmit.setAttribute("onClick", 
                    "alert('You must select your name before continuing.')");

    } else {
         usrSubmit.setAttribute("onClick", "pOff('p1');pOn('p2');");
    }
}
window.onload = usernamef();
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mapping CTRL+Click as right click using xmodmap in Modular X.Org 7 on Gentoo amitron Linux - General 0 10-12-2006 11:25 AM
Mandriva 2006 Programs stop working, or starting when i click them gravediggergnome Linux - Newbie 1 10-01-2006 09:34 AM
Azureus not working, Help! I click on the program & application dissappear suse2166 Linux - Software 4 12-20-2005 06:43 PM
'Click Here to Find Similar Threads' not working? titanium_geek LQ Suggestions & Feedback 5 06-24-2005 09:01 PM
How do I use keyboard commands if my pointing device is not working Like click onto K Maurice Arthur Linux - General 2 02-05-2004 03:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration