User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,500 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 5371 | Replies: 5
Reply
Join Date: Aug 2007
Posts: 57
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Form has no properties in FireFox... Works in IE

  #1  
Nov 6th, 2007
I am trying to submit a form with .submit(), but I am having issues passing the values from my form...

Here is what I have so far:
  1. <TITLE>ASPXTOASP.aspx</TITLE>
  2. <script language="C#" runat="server">
  3.  
  4. private void Page_Load(object sender, EventArgs e){
  5. //We grab all the session variable names/values and stick them in a form
  6. // and then we submit the form to our receiving ASP page (ASPTOASPX.asp)...
  7.  
  8. Response.Write("<form name=t id=t action=ASPXTOASP.asp method=post>");
  9.  
  10. foreach(object it in Session.Contents)
  11. {
  12. Response.Write("<input type=hidden name=" + it.ToString());
  13. Response.Write(" id=" + it.ToString());
  14. Response.Write( " value=" + Session[it.ToString()].ToString() + " >");
  15. }
  16.  
  17. if (Request.QueryString["destpage"] !=null)
  18. Response.Write("<input type=hidden name=destpage value=" +Request.QueryString["destpage"].ToString() +">");
  19. Response.Write("</FORM>");
  20. Response.Write("<scr" + "ipt>t.submit();</scr" + "ipt>");
  21. }
  22.  
  23. </script>
  24.  

As luck would have it, I have no problems with this in IE. I have tried everything that I can think of to get it to work in Firefox... document.forms(0).submit(), document.getElementById("t").value.submit, etc, and nothing is working.

Thanks!
Last edited by rrocket : Nov 6th, 2007 at 2:46 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 57
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Re: Form has no properties in FireFox... Works in IE

  #2  
Nov 6th, 2007
Anyone have any ideas?
Reply With Quote  
Join Date: Aug 2007
Posts: 57
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Re: Form has no properties in FireFox... Works in IE

  #3  
Nov 6th, 2007
If anyone has another other ideas I am definitely open... I am trying to pass session variables from an ASPX page to an ASP page. Like I mentioned before it works fine in IE, but not in Firefox. If it could be rewritten in javascript or something else please let me know. The major issue that I am having is getting the form values t not to cause a "has no properties error".
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 971
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Form has no properties in FireFox... Works in IE

  #4  
Nov 7th, 2007
document.getElementById("t").submit( ), or document.forms["t"].submit(); should work.. It may be the case that the inline script isn't running at the right time, or that the form cant be auto-submitted from inline script... if that was the case you'd need a body 'onload' handler in javascript to invoke the submission of the form.. but, I can't see a good reason why inline submit should be problem.

If it still doesn't work with either those changes, please post the HTML output ( via View Source ) when that page is accessed in the browser.

That's a really messy way to pass values between two scripts sitting on the same server.. Don't you think it's a good idea to include a <html>, <head>, <body> element, and to quote the attributes of elements? Dunno if ASP decides to add/fix those things for you on output.. so ignore that comment if that's the case.
Plato forgot the nullahedron..
Reply With Quote  
Join Date: Aug 2007
Posts: 57
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Re: Form has no properties in FireFox... Works in IE

  #5  
Nov 7th, 2007
Here is the HTML that view source gives me. It is passing everything I need to the browser...

  1. <form name=t id=t action=ASPXTOASP.asp method=post><input type=hidden name=username id=username value=cpio@email.com ><input type=hidden name=password id=password value=mypw ><input type=hidden name=destpage id=destpage value=login.asp></FORM><TITLE>ASPXTOASP.aspx</TITLE>

I changed the code a little, but it did not make a difference...

<script language="C#" runat="server">

private void Page_Load(object sender, EventArgs e){

    Response.Write("<form name=t id=t action=ASPXTOASP.asp method=post>");
    foreach(object it in Session.Contents)
	{
		Response.Write("<input type=hidden name=" + it.ToString());
        Response.Write(" id=" + it.ToString());
        Response.Write(" value=" + Session[it.ToString()].ToString() + " >");
        
    }
   
if (Request.QueryString["destpage"] !=null)
Response.Write("<input type=hidden name=destpage id=destpage value=" +Request.QueryString["destpage"].ToString() +">");

    Response.Write("</FORM>");
        
}

</script>

<script language="javascript">
//alert(document.forms["t"].submit());
document.forms["t"].submit();
</script>
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 971
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: Form has no properties in FireFox... Works in IE

  #6  
Nov 7th, 2007
Well.. I notice your javascript has disapeared from the output.. Why did you change the way you were outputing it? When I said, don't put the Javascript inline... that isn't exactly what I meant.

Certainly output a valid HTML document. Firefox is a bit nitpicky about standards.. What is printed is interpretted as a document, and whilst you can get quite... badly formed documents that still 'work', I'd advise that everytime you output anything to the browser; even something as short and invisible as this; that you make sure the document it is encapsulated in is a halfway valid document..

So.. I'm gonna tell you what you should try and get your script to output.. I'm not gonna rewrite your server script.. I'll leave that to you.. I've quoted attributes, which might seem a problem since you're allready quoting strings.. I've tried as hard as possible to only use single quotes; but there are a few places where I had to use double quotes... You'll have to escape those double quotes. If you don't know how.. read bottom few lines of this post.

Ok. You want your server script to output this exact HTML. It works, in Firefox, and Opera.

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ASPXTOASP.aspx</TITLE>
  5. </HEAD>
  6. <BODY onload='document.forms["t"].submit( );'>
  7.  
  8. <FORM name='t' id='t' action='ASPXTOASP.asp' method='post'>
  9. <INPUT type='hidden' name='username' id='username' value='cpio@email.com' >
  10. <INPUT type='hidden' name='password' id='password' value='mypw' >
  11. <INPUT type='hidden' name='destpage' id='destpage' value='login.asp' >
  12. </FORM>
  13.  
  14. </BODY>
  15. </HTML>

To escape the double quotes; like in the first 'DOCTYPE' part, use a backslash directly before any " that's within " quotes. Otherwise, the string ends abrubtly.

  1. Response.Write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");

The only other place where double quotes appear in that HTML are around the 't' here: <BODY onload='document.forms["t"].submit( );'>
Last edited by MattEvans : Nov 7th, 2007 at 12:14 pm.
Plato forgot the nullahedron..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC