|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
You don't have an action="" in your form tag. Also form.submit(); should work.
|
|
#3
|
||||
|
||||
|
You also need more than one value for your select statement so you can actually 'change' to a new value
|
|
#4
|
|||
|
|||
|
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>
|
|
#5
|
||||
|
||||
|
Quote:
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"> Last edited by ajax : October 5th, 2006 at 10:06 AM. |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
@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 |
|
#8
|
||||
|
||||
|
Quote:
Quote:
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! |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Javascript onchange submit not working |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|