An unforeseen issue with the behaviour I did not spot.
Using Option 1, and press Order (the hidden div contains a select menu) then the first value of this hidden select menu gets sent to Reflector
Array
(
[List1] => Option 1
[message] => Array
(
[0] => -8.00
)
)
I need to exclude these values if “prescription” is “not” selected
Demo here:
http://www.printlineadvertising.co.uk/demo/menuselect/getting-nearer.html
–
David
On 1 Jul 2010, at 17:13, Walter Lee Davis wrote:
See if changing Submit to submit in the observer function has any effect on the problem. Just this line:
$(document.forms[0]).observe(‘submit’,strip_hidden);
It seemed to help here.
Walter
On Jul 1, 2010, at 12:02 PM, David Owen wrote:
OK got that, and moved the second part inside the first no errors.
(BTW I’m NOT using the Protaculous Action in this instance, I’m using code direct in the “before ” section on Freeway)
the form sends to Reflector
But this still showing the hidden field data sent by the form
Array ( [List1] => Option 1 [message_title] => Array ( [0] => Prescription Code: ) [message] => Array ( [0] => ) )
–
David
On 1 Jul 2010, at 16:15, Walter Lee Davis wrote:
This error means that the page does not have a form on it. Which shouldn’t be possible. But it might be explained thus: At the moment that the script runs, the code that describes the form object has not been downloaded to the browser.
You need to do one of two things. The easiest would be to move the entire script, starting with function strip_hidden… and ending before the end-script tag, inside the document.observe block. This Pastie shows before and after, and I admit the difference appears subtle: http://pastie.org/1026711
What this does is place all of your code inside another “listener” function, which waits until the document has entirely downloaded to the browser (but usually before the page has become visible) and then fires off your code. It guarantees that everything is ready for the code, but doesn’t require that you break your JavaScript across multiple blocks placed throughout the page. And in most cases, it readies the effect before anything is visible on the page. This keeps you from having the “flash of scripted content”, where you see something for a fraction of a second and then it disappears as the page is set up for some visual effect.
You can get the same effect by using the Protaculous Action to place the code on the page. If you click on either of the Function Body buttons in Protaculous, you will get a code editing window where you can place a lump of code. The top button wraps your code inside the ‘dom:loaded’ listener function, which means (sorry for shouting) YOU HAVE TO REMOVE THAT from your code. If you were to remove the first line and the last line from my corrected script, and paste that inside the top Function Body dialog in Protaculous, you would end up with the same code.
The second button is for a different event: Event.observe(window,‘load’,function(evt){ your code here }); The reason you might want to use this versus the other has to do with timing. On a large page, you might have tons of photos or other resources that take a while to download. You want your script to do something visual with the page, but you want it to wait until everything is visible to start. So then you would use the second button and put your code there.
Walter
On Jul 1, 2010, at 9:34 AM, David Owen wrote:
I’m getting an error
TypeError: Result of expression '$(document.forms[0])' [undefined] is not an object.
Google is not really helping me with this probably because I understand what “//to apply it, set a listener on the form’s submit event:” means but not entirely sure where/how to implement it.
–
David
On 1 Jul 2010, at 09:36, David Owen wrote:
0 Jun 2010, at 17:24, Walter Lee Davis wrote:
This script will fix that.
function strip_hidden(evt){ evt.stop(); var f = $(this); f.getElements().each(function(elm){ if(!elm.visible() || elm.ancestors().find( function(m){ return ! m.visible(); }) ){ elm.remove(); } }); f.submit(); } //to apply it, set a listener on the form's submit event: $(document.forms[0]).observe('submit',strip_hidden);
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options