Reply to topic
Javascript OnClick
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 766
Location: Newark, De
Reply with quote
How would I get an OnClick event in JS to act like a hyperlink? I want to make a checkbox that says "click here to make my profile private" and when someone checks it the page refreshes with a URL variable that I can detect and effect a change to my database from.
bobclingan
Forum Regular

Joined: 16 Sep 2004
Posts: 271
Location: Abingdon, MD
Reply with quote
<input type="button" value="Click Me Baby One More Time" onClick="location.href='http://www.britneyspears.com'">
ccl


Joined: 29 Jun 2005
Posts: 15
Reply with quote
Assuming that your check box is in a form and that the form submits to a page that updates your database and then as you indicated, returns to the form page, you can have the form submit as soon as the check box is clicked by using the Javascript Submit() method.

exammple:
onclick="document.forms.formName.submit()"
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 766
Location: Newark, De
Reply with quote
Both great options - thanks guys!
Connie


Joined: 26 Mar 2005
Posts: 176
Location: The Internet
Reply with quote
I award bobclingan extra points for presenting his example with style Cool Laughing .
do the same thing but change the page in a frame only
scottjo


Joined: 14 Jul 2005
Posts: 1
Reply with quote
bobclingan wrote:
<input type="button" value="Click Me Baby One More Time" onClick="location.href='http://www.britneyspears.com'">


is there a way to do this same thing with a button but address a frame as the target?
bobclingan
Forum Regular

Joined: 16 Sep 2004
Posts: 271
Location: Abingdon, MD
Reply with quote
Sure, you would do something like this:

<input type="button" value="Oops I did it again!" onClick="parent.framename.location.href='http://www.britneyspears.com'">


Where framename is the name of the frame you wish to target.
Javascript OnClick
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic