2 Replies - 429 Views - Last Post: 23 August 2012 - 09:29 PM

#1 iheartbreakz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 196
  • Joined: 27-April 11

on click function not working

Posted 23 August 2012 - 09:16 PM

i want an alert to show when the upload button is clicked without checking the checkbox

here's my code:

<div id="upload" onclick="handleClick();">
Loading...
</div>

<input id="TOS" type="checkbox" name="tos" value="1" />

function handleClick()
{
	if(document.getElementById('TOS') != undefined && document.getElementById('TOS').checked != true)
	{
		alert('Please agree to Terms');
		return;
	}

	document.getElementById('upload').click();
}


This post has been edited by Martyr2: 23 August 2012 - 09:22 PM
Reason for edit:: Please use code tags in the future, thanks! :)


Is This A Good Question/Topic? 0
  • +

Replies To: on click function not working

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4316
  • View blog
  • Posts: 12,095
  • Joined: 18-April 07

Re: on click function not working

Posted 23 August 2012 - 09:25 PM

Did you put that javascript inside of script tags?
Was This Post Helpful? 0
  • +
  • -

#3 iheartbreakz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 196
  • Joined: 27-April 11

Re: on click function not working

Posted 23 August 2012 - 09:29 PM

yes its executed in a separate .js file which is linked with my main page but i think the problem is the use of the div tag. i put that divider tag because my upload field is Flash object so the click function is executing in the flash object.. is there any way i can make this work?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1