[Proto-Scripty] Re: forms trouble

2011-05-31 Thread kstubs
I'm curious about the form submit behavior, I'm starting a new topic on the 
subject.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: forms trouble

2011-05-03 Thread DMOL
Ok, so now I'm ignoring the buttons and just focusing on the form
elements:
There is now only one form - When submitted in search context, it
displays a number of new form elements which are subsequently
processed on re-submit.

The problem is that the new form elements do not appear until the
'search' form has been submitted and prior to this, the JS code
is complaining that the new elements are null. I've tried testing for
these values being null or undefined without success.

I'm really stuck here!
How can I get the code to ignore undefined/null elements and process
them if they are otherwise valid?

Anyone? I'd really appreciate the help.

Thanks
Dave

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: forms trouble

2011-05-02 Thread kstubs
Better ways:

1) abandon window.onload and use:

document.observe('dom:loaded', function() {
 // my code here
});

2) abandon $('search_form').onsubmit and use:

var form = $('search_form');
Element.observe(form, 'submit', function() {
 // my code here
});

=== but, if you really wan't to be smart about handling the form submit, you 
should bind an event listener like this:
Element.observe(form, 'submit', handleFormSubmit.bindAsEventListener());

Now you need a function name handleFormSubmit with a first event argument 
parameter, so like this:

function handleFormSubmit(e) { }

e is now the event submit and lots of useful information is now available 
to you, for example the item that cause the submit event to occur,
IE., the button you just clicked.  So you would have:

function handleFormSubmit(e) { 
  // first things first, stop the event from propagating
  e.stop();

  // get element from event object
  var elm = e.element();
  
  // determine which button was clicked and call appropriate next code
  if(elm.readAttribute('value') == 'search')
  // call some code

  if(elm.readAttribute('value') == 'update')
  // call some other code
  
}

See if you can get the above working and we can carry on with the rest of it 
later.  By the way, if you aren't using Firefox developer tools like FireBug 
and the Web Developer toolbar, then you are missing out on some really 
killer tools.  Better get those very first.

Karl..

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: forms trouble

2011-05-02 Thread DMOL
Hi Karl,
Thanks for your help.
Yes I am using firebug but I'm generally new to JS and Prototype.

I've adopted the approach you suggested but I can't seem to determine
which button is being pressed.

Search form:
form method=post action=null  id=search_form value=search-
submit
..
input id=search type=submit value=search name=search /

When the results from the DB are displayed, a new button is displayed
under the form:
input id=search type=submit value=update-submit /

And the old (search) submit button is hidden so that only the 'update'
button is now visible:
$('search-submit').style.display = 'none';

When the new 'update' button is clicked, I should be able to detect
this and process the post variables but I keep seeing the first
'search' button being pressed even when I press the 'update' button.

QUESTIONS: 1/ How do I determine which button is pressed.
   2/ In the update context, when multiple post values submitted: How
do I process them without getting element is undefined problems?
Thanks Dave
---

JS code:
document.observe('dom:loaded', function()  {
var form = $('search_form');
Event.observe(form, 'submit', 
process.bindAsEventListener());
   });

function process(e){
e.stop();
var elm = e.element();
var v = elm.readAttribute('value');
var i = elm.readAttribute('id');
var n = elm.readAttribute('name');
alert('Value='+v+'');
alert('ID='+i+'');
alert('Name='+n+'');
if(elm.readAttribute('value') == 'search-submit') { search(); }
if(elm.readAttribute('value') == 'update-submit') { update(); }

}
function search()
{
alert('Search context');
new Ajax.Updater ('results', 'http://website/search_form',
{method:'post', postBody:'search='+$F('search')});
$('search-submit').style.display = 'none';
}
function update()
{
...
}

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Forms

2009-10-29 Thread Richard Quadling

2009/10/29 Russell Keith russell.ke...@aacreditunion.org:
 Ok, maybe I’m just being dense, but I am reading the API for forms and I am
 getting nothing from it.



 What is proper use of the $F utility and what can it do for me?  I have read
 the Form.Element.getValue and it means nothing to me.



 I have this form:



     form name=createPDF action=/pdf/pdf_process.php method=POST

     input type=hidden name=A_NAME value=John /

     input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? /

     input type=hidden name=A_BIRTH_DATE value=01/01/01 /

     input type=hidden name=L_NAME value=Jane /

     input type=hidden name=L_BIRTH_DATE value=01/01/01 /

     input type=hidden name=A_ACCOUNT value=1 /

     /form



 When I try to do alert($F(‘A_NAME’)); I get an ‘Object does not support this
 property or method’ error.  I get the same error when I try to submit the
 form with ‘document.createPDF.submit();’ is there something wrong with my
 form?

 


$F() returns the element. So,

alert($F('A_ACCOIUNT').value);

should be what you are looking for,

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Richard Quadling

2009/10/29 Richard Quadling rquadl...@googlemail.com:
 2009/10/29 Russell Keith russell.ke...@aacreditunion.org:
 Ok, maybe I’m just being dense, but I am reading the API for forms and I am
 getting nothing from it.



 What is proper use of the $F utility and what can it do for me?  I have read
 the Form.Element.getValue and it means nothing to me.



 I have this form:



     form name=createPDF action=/pdf/pdf_process.php method=POST

     input type=hidden name=A_NAME value=John /

     input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? /

     input type=hidden name=A_BIRTH_DATE value=01/01/01 /

     input type=hidden name=L_NAME value=Jane /

     input type=hidden name=L_BIRTH_DATE value=01/01/01 /

     input type=hidden name=A_ACCOUNT value=1 /

     /form



 When I try to do alert($F(‘A_NAME’)); I get an ‘Object does not support this
 property or method’ error.  I get the same error when I try to submit the
 form with ‘document.createPDF.submit();’ is there something wrong with my
 form?

 


 $F() returns the element. So,

 alert($F('A_ACCOIUNT').value);

 should be what you are looking for,

 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling



OOps.

Completely wrong.

The form elements do not have IDs, so you need to add them for $F() to work.

http://api.prototypejs.org/dom/form/element.html#getvalue-class_method

See that the parameter is an element.
-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Walter Lee Davis

Try giving your form elements IDs to match their NAME property. I have  
always needed the ID to be set in order to get a value out of $F.

Walter

On Oct 29, 2009, at 11:08 AM, Russell Keith wrote:

 Ok, maybe I’m just being dense, but I am reading the API for forms  
 and I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I  
 have read the Form.Element.getValue and it means nothing to me.

 I have this form:

 form name=createPDF action=/pdf/pdf_process.php  
 method=POST
 input type=hidden name=A_NAME value=John /
 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? 
  /
 input type=hidden name=A_BIRTH_DATE value=01/01/01 /
 input type=hidden name=L_NAME value=Jane /
 input type=hidden name=L_BIRTH_DATE value=01/01/01 /
 input type=hidden name=A_ACCOUNT value=1 /
 /form

 When I try to do alert($F(‘A_NAME’)); I get an ‘Object does not  
 support this property or method’ error.  I get the same error when I  
 try to submit the form with ‘document.createPDF.submit();’ is there  
 something wrong with my form?

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Russell Keith

Then how is $F() any different than $()?

Also, any idea why I can't get my form to submit.  I have been all over
Google and can't figure it out.

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Walter
Lee Davis
Sent: Thursday, October 29, 2009 10:24 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Try giving your form elements IDs to match their NAME property. I have  
always needed the ID to be set in order to get a value out of $F.

Walter

On Oct 29, 2009, at 11:08 AM, Russell Keith wrote:

 Ok, maybe I'm just being dense, but I am reading the API for forms  
 and I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I  
 have read the Form.Element.getValue and it means nothing to me.

 I have this form:

 form name=createPDF action=/pdf/pdf_process.php  
 method=POST
 input type=hidden name=A_NAME value=John /
 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? 
  /
 input type=hidden name=A_BIRTH_DATE value=01/01/01 /
 input type=hidden name=L_NAME value=Jane /
 input type=hidden name=L_BIRTH_DATE value=01/01/01 /
 input type=hidden name=A_ACCOUNT value=1 /
 /form

 When I try to do alert($F('A_NAME')); I get an 'Object does not  
 support this property or method' error.  I get the same error when I  
 try to submit the form with 'document.createPDF.submit();' is there  
 something wrong with my form?

 





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Kevin Smith
You need to give the input tags an id, as follows:

form name=createPDF action=/pdf/pdf_process.php method=POST
input type=hidden id=A_NAME name=A_NAME value=John /
input type=hidden id=APPLY_DATE name=APPLY_DATE 
value=?=date(m/d/Y)? /
input type=hidden id=A_BIRTH_DATE name=A_BIRTH_DATE 
value=01/01/01 /
input type=hidden id=L_NAME name=L_NAME value=Jane /
input type=hidden id=L_BIRTH_DATE name=L_BIRTH_DATE 
value=01/01/01 /
input type=hidden id=A_ACCOUNT name=A_ACCOUNT value=1 /
/form

On 29/10/2009 15:08, Russell Keith wrote:

 Ok, maybe I'm just being dense, but I am reading the API for forms and 
 I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I 
 have read the |Form.Element.getValue and it means nothing to me.|

 | |

 |I have this form:|

 | |

 form name=createPDF action=/pdf/pdf_process.php method=POST

 input type=hidden name=A_NAME value=John /

 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? /

 input type=hidden name=A_BIRTH_DATE value=01/01/01 /

 input type=hidden name=L_NAME value=Jane /

 input type=hidden name=L_BIRTH_DATE value=01/01/01 /

 input type=hidden name=A_ACCOUNT value=1 /

 /form

 When I try to do alert($F('A_NAME')); I get an 'Object does not 
 support this property or method' error.  I get the same error when I 
 try to submit the form with 'document.createPDF.submit();' is there 
 something wrong with my form?


 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Russell Keith

Well, the issue was with my function name not the form.  I changed my
function name when I couldn't even get alert('test') to work.  It all
appears to be working now.

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Russell
Keith
Sent: Thursday, October 29, 2009 10:28 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Then how is $F() any different than $()?

Also, any idea why I can't get my form to submit.  I have been all over
Google and can't figure it out.

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Walter
Lee Davis
Sent: Thursday, October 29, 2009 10:24 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Try giving your form elements IDs to match their NAME property. I have  
always needed the ID to be set in order to get a value out of $F.

Walter

On Oct 29, 2009, at 11:08 AM, Russell Keith wrote:

 Ok, maybe I'm just being dense, but I am reading the API for forms  
 and I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I  
 have read the Form.Element.getValue and it means nothing to me.

 I have this form:

 form name=createPDF action=/pdf/pdf_process.php  
 method=POST
 input type=hidden name=A_NAME value=John /
 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? 
  /
 input type=hidden name=A_BIRTH_DATE value=01/01/01 /
 input type=hidden name=L_NAME value=Jane /
 input type=hidden name=L_BIRTH_DATE value=01/01/01 /
 input type=hidden name=A_ACCOUNT value=1 /
 /form

 When I try to do alert($F('A_NAME')); I get an 'Object does not  
 support this property or method' error.  I get the same error when I  
 try to submit the form with 'document.createPDF.submit();' is there  
 something wrong with my form?

 








--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Alex McAuley

because it gets values from anything (selects that can have multiples 
aswell) ...

Where as value on a multiple select would not.!!


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: Russell Keith russell.ke...@aacreditunion.org
To: prototype-scriptaculous@googlegroups.com
Sent: Thursday, October 29, 2009 3:27 PM
Subject: [Proto-Scripty] Re: Forms



Then how is $F() any different than $()?

Also, any idea why I can't get my form to submit.  I have been all over
Google and can't figure it out.

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Walter
Lee Davis
Sent: Thursday, October 29, 2009 10:24 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Try giving your form elements IDs to match their NAME property. I have
always needed the ID to be set in order to get a value out of $F.

Walter

On Oct 29, 2009, at 11:08 AM, Russell Keith wrote:

 Ok, maybe I'm just being dense, but I am reading the API for forms
 and I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I
 have read the Form.Element.getValue and it means nothing to me.

 I have this form:

 form name=createPDF action=/pdf/pdf_process.php
 method=POST
 input type=hidden name=A_NAME value=John /
 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)?
  /
 input type=hidden name=A_BIRTH_DATE value=01/01/01 /
 input type=hidden name=L_NAME value=Jane /
 input type=hidden name=L_BIRTH_DATE value=01/01/01 /
 input type=hidden name=A_ACCOUNT value=1 /
 /form

 When I try to do alert($F('A_NAME')); I get an 'Object does not
 support this property or method' error.  I get the same error when I
 try to submit the form with 'document.createPDF.submit();' is there
 something wrong with my form?

 








--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Forms

2009-10-29 Thread Rick . Wellman

$F() gets the *value* of the form element (i.e. a dropdown's value, the
text in a text box, etc.)
$() just gets the DOM element itself (so would return the dropdown, the
text box, etc. respectively).
[so also, using $F() on a non-form element is fairly pointless]

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Russell
Keith
Sent: Thursday, October 29, 2009 10:28 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Then how is $F() any different than $()?

Also, any idea why I can't get my form to submit.  I have been all over
Google and can't figure it out.

-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Walter
Lee Davis
Sent: Thursday, October 29, 2009 10:24 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: Forms


Try giving your form elements IDs to match their NAME property. I have  
always needed the ID to be set in order to get a value out of $F.

Walter

On Oct 29, 2009, at 11:08 AM, Russell Keith wrote:

 Ok, maybe I'm just being dense, but I am reading the API for forms  
 and I am getting nothing from it.

 What is proper use of the $F utility and what can it do for me?  I  
 have read the Form.Element.getValue and it means nothing to me.

 I have this form:

 form name=createPDF action=/pdf/pdf_process.php  
 method=POST
 input type=hidden name=A_NAME value=John /
 input type=hidden name=APPLY_DATE value=?=date(m/d/Y)? 
  /
 input type=hidden name=A_BIRTH_DATE value=01/01/01 /
 input type=hidden name=L_NAME value=Jane /
 input type=hidden name=L_BIRTH_DATE value=01/01/01 /
 input type=hidden name=A_ACCOUNT value=1 /
 /form

 When I try to do alert($F('A_NAME')); I get an 'Object does not  
 support this property or method' error.  I get the same error when I  
 try to submit the form with 'document.createPDF.submit();' is there  
 something wrong with my form?

 







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: forms - serialize and more

2009-03-10 Thread Bhudda Ben

Hi Quleczka

All your suggestions look good and probably are great technique for
getting this done.  BUT, no matter what I do, no matter ghow I code
this - and I have now tried at least a dozen different ways, I get the
exact same problem - as soon as I address my form, I get an error -
either firefox says the form has no properties or it just hangs at the
place where I address (serialize, do form request, etc) the form.  If
I take AJAX out, and just let normal submission occur, correct
processing occurs and I can reload the original page in its entirety
(redirect).  Normal AJAX Updater processing works, but as soon as I
use a form... boom!!!

I am at my wits end - I could experiment with doing this right aka
some of your suggestions (and BTW - at first there was no 'good'
response, just attempt to do what you suggest - load 'MiddleContent'
directly from the form processor - but no form is working here.  Could
there possibly be some other conflict with jQuery or ???

Thanks for your suggestions tho.

Ben

On Mar 9, 3:14 pm, Quleczka qulec...@gazeta.pl wrote:
 Hi,

 First of all I'm not prototype expert, rather newbie ;)

 1) why do you use onsubmit=validatethis();  if you can use  $
 ('formlinks').observe('submit',validatethis);

 2) you don't have to set asynchronous:true - it's default value

 3) most common is  parameters: $('formlinks').serialize(true) than
 using postBody

 4) use  parameters: { dept: $F('dept'), reg: $F('reg') } instead of
 this long  postBody:'dept='+department+'reg='+region ...this looks
 really bad !!! ;)

 you can also try to use $('formname').serializeElements( elements
 selection go here)

 for example $('formname').getInputs('text') which selects all input
 textfields from the same form or something similar ...you can use
 Element.select() or $$() if these elements have something in common
 (like class, type etc.) - any group of elements can go into
 serializeElements()

 5) where do you use mlprerresult variable? cause there is quite big
 chance that you don't have this variable set by ajax request cause
 before loadMenu() is called

 6) as far as I understand logic of  this app it would be better to
 call  loadmenu(); inside reportresult(); than it's sure it is called
 only after success of  ajax request

 7) can't you get this data from 'site/traderhomecenter.php' or 'site/
 adminhomecenter.php in response of first ajax request already? are
 the  values  $F('mlptrader'); $F('mlpdepartment');  etc. from form
 'formlinks'?

 if yes... you passed it all to the server already in first ajax
 request ... so can't you make one more php file which will calls
 'Admin/editmylinks2' inside and instead of returning just 'good'
 returns result of traderhomecenter.php or adminhomecenter.pl? or just
 change editmylinks2 to return this?

 you can send good if you want is x-json header of the same ajax
 response and in the body you can send html which you want to use to
 update  MiddleContent'

 simple example of php
 --
 $response = array ('good'=true);
 header('X-JSON: ('.json_encode($response).')');
 if ($_POST('mlptrader'))
    die (variable with html you get from traderhomecenter);
 else
    die (variable with html you get from adminhomecenter);
 
 and then in javascript

 function reportresult(transport) {
         var good = transport.headerJSON.good;
         if (good){
                 document.getElementById(mlprerresult).innerHTML =
 'Your request
 completed successfully';

 //instead of ajax updater just update $('Middle Contect').innerHTML
 here with what you have in transport.responseText
         }else
                 document.getElementById(mlprerresult).innerHTML =
 'Your request
 failed!!!';
 -

 These are my thought to make it easier but I'm not sure I understand
 correctly logic of your application.

 Quleczka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: forms - serialize and more

2009-03-10 Thread Bhudda Ben

For the first time something is happening - though I am not sure what.

Explorer is hanging up after giving a 'null' response for the alert
below - but, firefox is not even hitting the alert and is processing
normally, thogh it does not have the code to complete the AJAX
request, just redirects to redo the original page.  Can someone please
tell me what is going on

form method=post id=formlinks name=formlinks action=Admin/
editmylinks2.php onsubmit=$('formlinks').observe
('submit',validatethis);

validatethis = function()
{
submitOK=true;
  sometests...
  if (((text1.length  1  url1.length  0) || (text1.length  0 
url1.length  1)) || ((text2.length  1  url2.length  0) ||
(text2.length  0  url2.length  1)) || ((text3.length  1 
url3.length  0) || (text3.length  0  url3.length  1))){
alert(If you enter link text, you must enter a URL and 
vice-
versa);
submitOK = false;
}
if (submitOK == false){
return false;
} else {
loadingScreen('MiddleContent','Loading...'); // working for IE;
firefox not getting here - is taking different route to process code
postIt('formlinks');

}
}

function postIt(theform) {
var form = $(theform);
alert (form);  // as said, firfox not goingt here, but IE reports
'null' for this alert
form.request({
onComplete: function() { alert ('good') }
})
}


(I assume Firefox is just going directly to action of form, but do not
know why)

Ben


On Mar 10, 10:04 am, Bhudda Ben benjamin.rud...@gmail.com wrote:
 Hi Quleczka

 All your suggestions look good and probably are great technique for
 getting this done.  BUT, no matter what I do, no matter ghow I code
 this - and I have now tried at least a dozen different ways, I get the
 exact same problem - as soon as I address my form, I get an error -
 either firefox says the form has no properties or it just hangs at the
 place where I address (serialize, do form request, etc) the form.  If
 I take AJAX out, and just let normal submission occur, correct
 processing occurs and I can reload the original page in its entirety
 (redirect).  Normal AJAX Updater processing works, but as soon as I
 use a form... boom!!!

 I am at my wits end - I could experiment with doing this right aka
 some of your suggestions (and BTW - at first there was no 'good'
 response, just attempt to do what you suggest - load 'MiddleContent'
 directly from the form processor - but no form is working here.  Could
 there possibly be some other conflict with jQuery or ???

 Thanks for your suggestions tho.

 Ben

 On Mar 9, 3:14 pm, Quleczka qulec...@gazeta.pl wrote:



  Hi,

  First of all I'm not prototype expert, rather newbie ;)

  1) why do you use onsubmit=validatethis();  if you can use  $
  ('formlinks').observe('submit',validatethis);

  2) you don't have to set asynchronous:true - it's default value

  3) most common is  parameters: $('formlinks').serialize(true) than
  using postBody

  4) use  parameters: { dept: $F('dept'), reg: $F('reg') } instead of
  this long  postBody:'dept='+department+'reg='+region ...this looks
  really bad !!! ;)

  you can also try to use $('formname').serializeElements( elements
  selection go here)

  for example $('formname').getInputs('text') which selects all input
  textfields from the same form or something similar ...you can use
  Element.select() or $$() if these elements have something in common
  (like class, type etc.) - any group of elements can go into
  serializeElements()

  5) where do you use mlprerresult variable? cause there is quite big
  chance that you don't have this variable set by ajax request cause
  before loadMenu() is called

  6) as far as I understand logic of  this app it would be better to
  call  loadmenu(); inside reportresult(); than it's sure it is called
  only after success of  ajax request

  7) can't you get this data from 'site/traderhomecenter.php' or 'site/
  adminhomecenter.php in response of first ajax request already? are
  the  values  $F('mlptrader'); $F('mlpdepartment');  etc. from form
  'formlinks'?

  if yes... you passed it all to the server already in first ajax
  request ... so can't you make one more php file which will calls
  'Admin/editmylinks2' inside and instead of returning just 'good'
  returns result of traderhomecenter.php or adminhomecenter.pl? or just
  change editmylinks2 to return this?

  you can send good if you want is x-json header of the same ajax
  response and in the body you can send html which you want to use to
  update  MiddleContent'

  simple example of php
  --
  $response = array ('good'=true);
  header('X-JSON: ('.json_encode($response).')');
  if ($_POST('mlptrader'))
     die (variable with html you get from traderhomecenter);
  else
     die (variable with html you get from adminhomecenter);
  
  and then in javascript

 

[Proto-Scripty] Re: forms - serialize and more

2009-03-10 Thread Quleczka

 Explorer is hanging up after giving a 'null' response for the alert
 below - but, firefox is not even hitting the alert and is processing
 normally, thogh it does not have the code to complete the AJAX
 request, just redirects to redo the original page

If you don't use event.stop() for is just submitted without waiting
for anything from ajax...

you have mess in your code... I fixed it and posted here 
http://pastie.org/413066

it is working now :)

you don't use observe in onSubmit...it is pointless :)

as soon as I address my form, I get an error -
either firefox says the form has no properties or it just hangs at
the
place where I address 

No one can't help you with this serializing problem without some
simplified working example of  your form.

By the way are you using firebug to debug this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: forms - serialize and more

2009-03-09 Thread Bhudda Ben

as additional info, I should mention:

there are multiple forms - tho with much different names

jQuery is also loaded which at first gave me conflicts, but
Ajax.Updater, at least, working now

the form giving me problem is itself loaded via Ajax.Updater - along
with (using eval) the script 'validatethis' (and others, which seem to
be working)

...

On Mar 9, 12:09 pm, Bhudda Ben benjamin.rud...@gmail.com wrote:
 Hi

 I have a rather large complicated form that changes considerably based
 on database content and user interaction - therefore, I said to
 myself, I need to serialize ??

 The whole is I wish to serialize form elements, pass them to php
 (Admin/editmylinks2.php)  - which would update database (working) and
 then write the word 'good' back to page which would be processed by
 (reportresult) and then the loadmenu function would bring content to
 my div 'MiddleContent'.

 My current problem is with the serialization process - I am getting
 'form formlinks has no properties' error in FireFox errorconsole.  But
 I also want to ask about my technique in general - the serialize form
 followed by AjaxRequest followed by loadmenu function which calls
 Ajax.Updater...

 form method=post id=formlinks name=formlinks action=Admin/
 editmylinks2.php onsubmit=validatethis();

 validatethis = function()  // this function arrives through AJAX with
 the form, that seems OK; other functions (loadmenu, reportresult,
 loadingScreen) arrive with original page
 {
         // bunch of error checking here which if there are errors makes
 submitOK = false
         if (submitOK == false){
                 return false;
         } else {
                 loadingScreen('MiddleContent','Loading...');
                 var parms = $('formlinks').serialize(true);
                 new Ajax.Request('Admin/editmylinks2.php', {asynchronous:true,
 postBody:parms, onSuccess:reportresult});
                 loadmenu();
         }

 }

 function reportresult(transport) {
         var response = transport.responseText;
         if (response == 'good')
                 document.getElementById(mlprerresult).innerHTML = 'Your 
 request
 completed successfully';
         else
                 document.getElementById(mlprerresult).innerHTML = 'Your 
 request
 failed!!!';

 }

 function loadMenu() {
         var trader = $F('mlptrader');
         var department = $F('mlpdepartment');
         var region = $F('mlpregion');
         var office = $F('mlpoffice');
         var user = $F('mlpuser');
         var jack = 'Y';
         loadingScreen('MiddleContent','Loading Navigation');
         if (trader) {
                 new Ajax.Updater('MiddleContent', 'site/traderhomecenter.php',
 {asynchronous:true, postBody:'dept='+department+'reg='+region
 +'off='+office+'user='+user+'jack='+jack, onlyLatestOfClass:
 'Ajax.Updater'});
         } else {
                 new Ajax.Updater('MiddleContent', 'site/adminhomecenter.php',
 {asynchronous:true, postBody:'dept='+department+'reg='+region
 +'off='+office+'user='+user+'jack='+jack, onlyLatestOfClass:
 'Ajax.Updater'});
         }

 }

 All help greatly appreciated
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: forms - serialize and more

2009-03-09 Thread Quleczka

Hi,

First of all I'm not prototype expert, rather newbie ;)

1) why do you use onsubmit=validatethis();  if you can use  $
('formlinks').observe('submit',validatethis);

2) you don't have to set asynchronous:true - it's default value

3) most common is  parameters: $('formlinks').serialize(true) than
using postBody

4) use  parameters: { dept: $F('dept'), reg: $F('reg') } instead of
this long  postBody:'dept='+department+'reg='+region ...this looks
really bad !!! ;)

you can also try to use $('formname').serializeElements( elements
selection go here)

for example $('formname').getInputs('text') which selects all input
textfields from the same form or something similar ...you can use
Element.select() or $$() if these elements have something in common
(like class, type etc.) - any group of elements can go into
serializeElements()

5) where do you use mlprerresult variable? cause there is quite big
chance that you don't have this variable set by ajax request cause
before loadMenu() is called

6) as far as I understand logic of  this app it would be better to
call  loadmenu(); inside reportresult(); than it's sure it is called
only after success of  ajax request

7) can't you get this data from 'site/traderhomecenter.php' or 'site/
adminhomecenter.php in response of first ajax request already? are
the  values  $F('mlptrader'); $F('mlpdepartment');  etc. from form
'formlinks'?

if yes... you passed it all to the server already in first ajax
request ... so can't you make one more php file which will calls
'Admin/editmylinks2' inside and instead of returning just 'good'
returns result of traderhomecenter.php or adminhomecenter.pl? or just
change editmylinks2 to return this?

you can send good if you want is x-json header of the same ajax
response and in the body you can send html which you want to use to
update  MiddleContent'

simple example of php
--
$response = array ('good'=true);
header('X-JSON: ('.json_encode($response).')');
if ($_POST('mlptrader'))
   die (variable with html you get from traderhomecenter);
else
   die (variable with html you get from adminhomecenter);

and then in javascript

function reportresult(transport) {
var good = transport.headerJSON.good;
if (good){
document.getElementById(mlprerresult).innerHTML =
'Your request
completed successfully';

//instead of ajax updater just update $('Middle Contect').innerHTML
here with what you have in transport.responseText
}else
document.getElementById(mlprerresult).innerHTML =
'Your request
failed!!!';
-

These are my thought to make it easier but I'm not sure I understand
correctly logic of your application.

Quleczka


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---