tags:

views:

36

answers:

2

Hello friends. In the html form given below, the user posts a value resid1, which is matched with the resid stored in the database.

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<form name="form1" method="post" action="honda.php","tomcat\webapps\blazeds\e2.html">

Now if you will see the action field in the form, i want to post this value of resid to two different forms. Is it possible. Nd secondly, honda.php is in the htdocs folder of the Apache webser thus the value is easily posted, but the e2.html file is stored in Tomcat Blazeds folder. Thus i am unable to post value in this html.

Please if any one can help me ASAP. This thing have stuck me from the last 2 days..

A: 

You could do something as described here.

Myles
Thankyou for the reply. Actually got it working. I added the code as told: function emailForm(f) { f.encoding = "multipart/form-data"; f.action = "honda.php"; f.onsubmit = "_self"; f.submit(); } function pageForm(f) { f.encoding = "multipart/form-data"; f.action = "experiment/e2.html"; f.onsubmit = "_self"; f.submit(); }.
Tourer
Tourer
+1  A: 

The way you are attempting this is not possible. A browser will only submit a form once, to the URL specified by the action attribute. This is a fundamental browser behaviour that cannot be changed.

However, it is possible to work around the basic behaviour. In all cases you're going to require some Javascript manipulation, so it will only work if the user has JS enabled.

The basic approach would be to handle the form in the onsubmit event and manipulate it so that multiple URLs could be requested. You could utilize Ajax to make multiple requests, or you could even dynamically package the form data into another form element on the page and submit it.

Ajax would be the way I would approach it. There are excellent Ajax tools available that would facilitate this, such as JQuery.

For example, you could do something like this (I'm using JQuery here):

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1.3.2");</script>
<script type="text/javascript">
function handleForm()
{
    $.ajax({
     url: 'honda.php',
     data: $('#form1').serialize()
    });
    $.ajax({
     url: 'tomcat\webapps\blazeds\e2.html',
     data: $('#form1').serialize()
    });
    return false;
}

</script>
<form id="form1" onsubmit="return handleForm()" name="form1" method="post">
<!-- stuff -->
</form>
zombat
Thanks for the reply. But the point i am trying to make here is e2.html is placed in the Tomcat webapps folder nd not in Apache htdocs folder. So the browser cannot find the html in htdocs. So the problem remains. I can use the code provided by you for my input form. But when u say url: 'tomcat\webapps\blazeds\e2.html, i cannot open it here. Any solutions please.... Thanks again for the reply..
Tourer
A browser will never be able to find a page that does not have a URL. You have to make the tomcat page accessible via the web if you want to be able to submit a form to it. Your browser must be able to access it somehow, even if it's by the "file://" protocol instead of "http://".
zombat