Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-15-2013, 04:02 AM   PM User | #1
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
After submit, refresh page automatically

I'm not a javascript expert ...

Here is what I'm trying to do.

I have a form with two radio buttons (On and Off).
When either radio button is clicked, I submit the form to a URL.
I then need to automatically refresh the page after the form is submitted.

This is what I have so far. It currently does submit the form, that works OK (by the way, it is submitting it to itself .. it's a PHP script). But then I need the page to refresh for updating some other things that PHP does.

Code:
<form id="myForm1" action="<?=$_SERVER['php_self']?>" method="post">
			OUTPUT 7:
			<input type="radio" id="but7" name="v" value="71" onClick="javascript: submit()"  onMouseOver="style.cursor='hand'"> ON
			<input type="radio" id="but7" name="v" value="70" onClick="javascript: submit()"  onMouseOver="style.cursor='hand'"> OFF
		</form>
mlseim is offline   Reply With Quote
Old 02-15-2013, 05:33 AM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
most likely you can edit the submit function to return true, or simply remove it the onclick function altogether and submit the form as you normally would.
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 02-15-2013, 09:24 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Wow, I’m wondering about the outdated code there? cursor: hand? That hasn’t been valid CSS ever and was only needed for some ancient version of Netscape if I recall correctly. It’s called “pointer” nowadays — and by the way: this can be done with CSS, with a simple line like
Code:
input[type=radio]:hover {cursor: pointer;}
As to the submit functionality: don’t use onclick on form controls, use onchange. Also get rid of the javascript: crap in the event handler. It’s only JavaScript that can be executed there, no need to announce that before. On submitting the form the page should refresh automatically, actually, so I don’t know what the problem is?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 02-15-2013, 12:57 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Thanks ... I'll work on it. It is old code I just copied and I was using it.
mlseim is offline   Reply With Quote
Old 02-15-2013, 01:12 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Oh and by the way: the name and id attributes must have unique values each, i. e. there can’t be two elements with the same name/ID in one document. Well, name is kind of an exception in that you can store the name in an array, i. e. give the names square brackets (like name="example[]" on multiple elements) and you can read it out with PHP like example[1] etc.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:19 AM.


Advertisement
Log in to turn off these ads.