JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 5th, 2006, 05:53 AM
andy11983 andy11983 is offline
Newbie wannabe extrodanaire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: stoke
Posts: 321 andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 10 h 36 m 19 sec
Reputation Power: 7
Javascript onchange submit not working

hi guys,

my javascript on change event submission is not firing, can anybody please help me.

Many thanks

andy

<form method="get" name="frmSummary">
<select name="dRangeStart" class="selector_wide" onChange="this.frmSummary.submit()">
<option value="10" selected>:: Please select ::</option>
</select>
__________________
ze man from delmontae say 'yes'
if i helped you please add to my reputation

Reply With Quote
  #2  
Old October 5th, 2006, 06:39 AM
mcjwb mcjwb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: UK
Posts: 151 mcjwb User rank is Lance Corporal (50 - 100 Reputation Level)mcjwb User rank is Lance Corporal (50 - 100 Reputation Level)mcjwb User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 8 h 33 m 23 sec
Reputation Power: 5
You don't have an action="" in your form tag. Also form.submit(); should work.

Reply With Quote
  #3  
Old October 5th, 2006, 07:41 AM
Ebot's Avatar
Ebot Ebot is offline
Meatball Surgeon
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2004
Location: Elbow deep in code
Posts: 1,823 Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)Ebot User rank is General 1st Grade (Above 100000 Reputation Level)  Folding Points: 77914 Folding Title: Intermediate FolderFolding Points: 77914 Folding Title: Intermediate FolderFolding Points: 77914 Folding Title: Intermediate FolderFolding Points: 77914 Folding Title: Intermediate Folder
Time spent in forums: 2 Weeks 1 Day 13 h 43 m
Reputation Power: 1045
You also need more than one value for your select statement so you can actually 'change' to a new value

Reply With Quote
  #4  
Old October 5th, 2006, 09:19 AM
andy11983 andy11983 is offline
Newbie wannabe extrodanaire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: stoke
Posts: 321 andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 10 h 36 m 19 sec
Reputation Power: 7
hi,

thanks forthe replys i have changed the form action so that it has a value, however it is still not working, i have enclosed the full scrip of the select box.

Thanks again

andy
Code:

	<select name="dRangeStart" class="selector_wide" onChange="form.submit()">  
			<!--- <select name="dRangeStart" class="selector_wide" onChange="alert(this.options[this.selectedIndex].value)"> --->
				<option value="-23" selected>:: Please select ::</option>
				<cfloop condition="datediff('m',dSomeDate,dEnd) gt -1">
					<cfset dSomeDate = dateadd("m",1,dSomeDate)>
					<cfif datediff('m',dSomeDate,dEnd) gte 0>
						<cfset sThisoptionDate = dateformat(dSomeDate,'mm/yyyy')>
						<cfoutput><option value="#sThisoptionDate#" <cfif isDefined("url.dRangeStart")><cfif sThisoptionDate eq url.dRangeStart>selected</cfif></cfif>> #dateformat(dSomeDate,"mmm yy")#</option></cfoutput>
					</cfif>
				</cfloop>
			</select>		

Reply With Quote
  #5  
Old October 5th, 2006, 10:02 AM
ajax's Avatar
ajax ajax is offline
Resident DJ
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 283 ajax User rank is Lance Corporal (50 - 100 Reputation Level)ajax User rank is Lance Corporal (50 - 100 Reputation Level)ajax User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 1 h 55 m 24 sec
Reputation Power: 9
Quote:
onChange="form.submit()"


form should be your form's Name or ID

So it should still be frmSummary

Edit: personally, I like to keep the onchange out of the <select> box and use IDs instead of names.

<form id="SummaryFormId">
<select id="SelectSummaryOption">

javascript Code:
Original - javascript Code
  1. <script>
  2. var submitform = function() {
  3.   SummaryFormId.submit()
  4. }
  5. document.getElementById('SelectSummaryOption').onchange = submitform;
  6. </script>

Last edited by ajax : October 5th, 2006 at 10:06 AM.

Reply With Quote
  #6  
Old July 18th, 2008, 10:14 AM
you_guys you_guys is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 you_guys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 27 sec
Reputation Power: 0
You_guys

You guys, I think I have found the solution, I had this problem also.

The thing is to rename the <input type='submit' name='submit' value'Submit' /> to something else like <input type='submit' name='post_this_form' value='Submit' />

I tried that and worked !!!!

PS: even if you need a post with the name submit and you try to insert a hidden field, with the name and value submit, it will still not work (<input type='hidden' name='submit' value='submit' />)

Hope this helps you guys

Reply With Quote
  #7  
Old July 18th, 2008, 11:52 AM
derelict's Avatar
derelict derelict is offline
dubiously dynamic detritus
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2006
Location: deftly drawn delusionary diagram
Posts: 800 derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level)derelict User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 12 h 48 m 25 sec
Reputation Power: 227
@you_guys -- this is a naming issue. forms have a method called 'submit', but if you give a form element the name 'submit' then javascript will not be able to find the .submit method, causing your .submit function to never fire.

@andy11983 --

what 'ajax' says is a good methodology -- something for you to learn about (good to note that the script provided must be run onload or at least declared after the select and form's close tags).

for the path of least resistance with your current code, simply change

Code:
onChange="form.submit()"


to
Code:
onChange="this.form.submit()"


the first method is looking for something called window.form (since window is the global object) which does not exist. the second is looking for the .form property of the select list, which is the form containing the select; i.e. the form you're looking to submit. that should work for you.

HTH - derelict

Reply With Quote
  #8  
Old January 27th, 2009, 09:21 PM
.Gogeta§§J4BR. .Gogeta§§J4BR. is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Location: São Paulo, SP, Brasil
Posts: 1 .Gogeta§§J4BR. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 58 sec
Reputation Power: 0
Send a message via MSN to .Gogeta§§J4BR. Send a message via Google Talk to .Gogeta§§J4BR.
Orkut
Quote:
Originally Posted by you_guys
You guys, I think I have found the solution, I had this problem also.

The thing is to rename the <input type='submit' name='submit' value'Submit' /> to something else like <input type='submit' name='post_this_form' value='Submit' />

I tried that and worked !!!!

PS: even if you need a post with the name submit and you try to insert a hidden field, with the name and value submit, it will still not work (<input type='hidden' name='submit' value='submit' />)

Hope this helps you guys

Quote:
Originally Posted by derelict
@you_guys -- this is a naming issue. forms have a method called 'submit', but if you give a form element the name 'submit' then javascript will not be able to find the .submit method, causing your .submit function to never fire.

I've registered here to say Thank you, thank you, thank you!!!
you_guys, you have just saved me from countless hours of !!! I can't believe I was this dumb (you know when this kind of stupid things get in our way, eh? )
Thank you, one more time!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Javascript onchange submit not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT