1

I am trying to create a hidden form with some data, which needs to be submitted to a jsp page (which gets open in a new window), but all this would happen programatically, without user pressing submit button.

My Sample code

var fsquery = "abcd";
var emailId = "as@gmail.com";
var portalPsswd = "password";
var projectId = "123";
var kbUrl = "some url which will consume form post parameters";
var pv="1.2",pn="ADA";

this.kbform=isc.DynamicForm.create({
width: 300,
fields: [
{type: "hiddenitem", name: "EMAIL_ID", defaultValue:emailId },
{type: "hiddenitem", name: "PORTAL_PASSWORD", defaultValue:portalPsswd},
{type: "hiddenitem", name: "PROJECT_ID", defaultValue:projectId},
{type: "hiddenitem", name: "FSQUERY", defaultValue:fsquery},
{type: "hiddenitem", name: "PRODUCT_VERSION", defaultValue:pv},
{type: "hiddenitem", name: "PRODUCT_NAME", defaultValue:pn},
{type: "hiddenitem", name: "ORIGIN", defaultValue:"Administrator"},
{type: "submit", name: "submit", defaultValue: "submit"}
],
action: kbUrl,
target: "_blank",
method: "POST",
canSubmit: true
});

this.kbform.submit();

the last statement does not submit the form automatically, but if I click the submit button provided, it works perfectly as needed.

Please provide me a solution which will help me simulate "submit" type button functionality to submit the form.

You can try this sample code here under "text.js" tab

AabinGunz
  • 12,109
  • 54
  • 146
  • 218

1 Answers1

0

I'm not sure about this, but have you tried triggering the submit on a window.onload event? I don't think the form is available until the document is fully loaded. I'm sorry I don't have any examples.

Insinbad
  • 108
  • 6
  • 1
    Thanks for your answer, even I suspect the same, somehow the `kbform.submit()` is getting called before the DynamicForm is fully loaded with values, how can I use somwthing like `window.onload` to submit the form? – AabinGunz Apr 02 '13 at 05:01
  • Here's a bit of code which wait for the page to load then calls a timer to delay half a second, check if the form has content, then submit or loop based on the results. That's a quick example of how I would go at it. `var fSubmit = function() { if () { } else { fResetTimer() } } var fResetTimer = function() { isc.Timer.setTimeout("fSubmit", 500) } window.onload=function(){ fResetTimer(); };` – Insinbad Apr 02 '13 at 08:24
  • 1
    This is how I solved the problem, 1st I created all the form elements without values and added it to the dialog (parent element), later I added values to it, so due to the delay in creating form items it was unable to find form to submit. thanks – AabinGunz Apr 02 '13 at 09:17