Skip to main content
October 20, 2008
Question

Form Variables Undefined After JavaScript submit

  • October 20, 2008
  • 3 replies
  • 539 views
I have a simple sample of a form with one text input. If I submit the form using an html submit input tag the form variables are available to the next page, but if I submit the form using JavaScript's submit() function (i.e. with an image map) they are undefined! Any idea why this might be happening?

I've attached foo.cfm and bar.cfm as an example.

This topic has been closed for replies.

3 replies

Inspiring
October 20, 2008
the following test code works fine in FireFox 3, Chrome, IE6, IE7,
IE8b2, Safari 4 (win) and Opera 9.5 (all on Win):

<cfdump var="#form#">
<form name="myform" method="post" action="">
<input type="text" name="mytext" /><br />
<input type="submit" name="send" value="send" />
</form>
<br />
<img src="img/tn_0000000001.png" onclick="myform.submit();" />

must be some issue with your image map if it does not work...


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
October 20, 2008
Thanks Azadi, it definitely is a problem with the imagemap. If I replace it with something like your suggestion (using the <img> tag) it works for me too. Any suggestions on how to troubleshoot the image map problem?
October 20, 2008
I moved the <img> tag and map inside the form, but it still doesn't work. I added <cfdump var="#form#"> to bar.cfm to see what variables ARE being passed, and it came back with "struct [empty]".
Inspiring
October 20, 2008
Hi,

Your <img> tag as well as the imagemap should be inside the <form> </form> tags.

Like this,