Programmatic Form Submission- am I stupid or what?
Cayenne - April 9, 2008 - 06:12
Okay this is driving me nuts. I've been crawling the site for hours
When my module is invoked, I want to automatically submit the form. For some reason, I seem not to be able to find the simplest of programmatic submissions of a form. A pointer please?
Here is the form creation code.
$form = array();
$form['#action'] = url('https://www.example.com/Memberstatement/memberstatements.cfm');
$form['#attributes'] = array('target' => '_blank');
$form['username'] = array(
'#name' => 'username',
'#type' => 'hidden',
'#value' => $myname,
);
$form['password'] = array(
'#name' => 'password',
'#type' => 'hidden',
'#value' => $mypass,
);
$form['submit'] = array (
'#type' => 'submit',
'#name' => 'submit',
'#value' => t('Check the Statements'),
);
return $form;
This example i have shown
This example i have shown has simple submit operation.
http://drupal.org/node/227103
I know you are trying to submit data onload the page . so automatically you don't need any submit button on your form. On performing some action you are opening a new tab so pass this username and password as POST (not save method) and save them using if(POST['username']) or save them in session then using javascript onpage load call a function, that will save them in the table.
I am not an expert in jquery (just read some tutorial). I think there are some functions to identify page load, end of page load etc. You can use them to call the function to save the data to the table(I am helpless in that).
Hope this will help.
Cheers.