tags:

views:

122

answers:

2
+1  Q: 

javascript post

hi, i have a javascript function, that i use to open a new window, post a form in this new window and check the results there. The code work fine in IE7, but don't work in FF3. Somebody knows why? I call this function in a button Onclick event:

function OpenEdit(id){
var sData;
var sDomain = "http://foobar.org/index.php?";
sData = "<form name='editUser' id='editUser' action='" + sDomain + "page=adm/update' method='post'>";
sData = sData + "<input type='hidden'  name='id' value='" + id + "'/>";
sData = sData + "</form>";
sData = sData + "<script type='text/javascript'>document.editUser.submit();</scr" + "ipt>";
OpenWindow=window.open("", "newwin");
OpenWindow.document.write(sData);
OpenWindow.document.close();
}

Regards, Victor

+5  A: 

Where are your tags

  • html
  • body

Add these and it might work better for you

function OpenEdit(id){
var sData;
var sDomain = "http://foobar.org/index.php?";
sData = "<html><body>"; 
sData = sData + "<form name='editUser' id='editUser' action='" + sDomain + "page=adm/update' method='post'>";
sData = sData + "<input type='hidden'  name='id' value='" + id + "'/>";
sData = sData + "</form>";
sData = sData + "<script type='text/javascript'>document.editUser.submit();</scr" + "ipt>";
sData = sData + "</body></html>"; 
OpenWindow=window.open("", "newwin");
OpenWindow.document.write(sData);
OpenWindow.document.close();
}
Paul Whelan
VP
No problemo glad I could help :)
Paul Whelan
+1  A: 

"Doesn't work" isn't very useful - give us a proper error message! In FF go to Tools -> Error Console, or press ctrl+shift+J.

At a guess, document.editUser.submit() should be document.forms['editUser'].submit()

Greg