PDA

View Full Version : Help


AsifTheManRahman
June 9, 2004, 08:14 PM
Ok. This time it's a JSP - HTML combo. I need the user to enter files (using the "browse" button) in my web page. As you know, this requires the use of a form in HTML. However, my page contains lots of other fields (e.g. name, address, etc) that the user has to input, and I require these fields to be printed on the next page (when the user clicks on the submit button at the bottom of the page). So, I need a form that will hold all of the fields, but since HTML doesn't allow holding forms within forms, my pages are not working properly. When I hit the submit button, nothing happens. I know this is happening because I am creating multiple "nested" forms. In the next page, I have used "request.getParameter" to get the values entered in the first page.

So I'll have to do what I am without using any forms. Please let me know if there's an alternative. The pages work fine if I remove the "browse" option, but I can't afford to do that.

Thanks

AsifTheManRahman
June 9, 2004, 08:33 PM
I was also wondering whether JavaScript has anything to offer.

Mahmood
June 9, 2004, 08:35 PM
I am not even clear on what you are trying to do or what the problem is. Please post the source pages.

Nasif
June 9, 2004, 09:11 PM
Thead moved to Forget Cricket
<hr>
From your description it is not clear what you are trying to do. If you trying to capture user entry in a form and want to dispaly it before it goes to the server side then you can simply use JavaScript alone to acomplish this.

I have done similar thing in our <a href=http://games.banglacricket.com/chat>Chat login page</a>. When user presses the buttong "Connect to #banglacricket", nothing is sent to server. As a matter of fact, that button is not "submit" either. Once pressed that button calls a function that overwrites the whole page with new HTML (resulting in a new page) based on the user's selection on that login form.

Please take a look at the source of that page. Look at the function NewWindow() and how it is called in the login form. It might be helpful.

You can write a completely new page with JavaScript:
self.document.clear();
self.document.write('HTML..page....string' ) ;


[Edited on 10-6-2004 by nasif]

AsifTheManRahman
June 9, 2004, 09:55 PM
Thanks. I'll take a look at it.

AsifTheManRahman
June 9, 2004, 10:02 PM
Ok that's exactly what I'm trying to do, except that I also have to prompt the user to input his resume, with the option of including an existing copy by browsing through his computer. That is when I'm having the problem. In order to let the user input files, I need a form which is separate to the one that I am using for the other inputs. Ok I know I'm not making sense so I'll send you the source code.

AsifTheManRahman
June 9, 2004, 10:06 PM
<form>
<table>
<tr><td> Name: </td><td><input type = "text"></td></tr>
<tr><td> Email: </td><td><input type = "text"></td></tr>
.
.
.
.
etc..etc...
</table>
</form>

<form method = "post">
<table>
<tr><td>Enter resume here</td><td>
<input type = "file" enctype = "multipart/form-data"></td></tr>
</table>
</form>

<form method = "post">
<input type = "submit" value = "Apply">
</form>


[Edited on 10-6-2004 by AsifTheManRahman]

[Edited on 6-10-2004 by chinaman : Forum layout restored]

AsifTheManRahman
June 9, 2004, 10:35 PM
Ok

This is somewhat similar to what I'm trying to do...I've used three different forms - one that holds all fields upto email, one that holds the resume field, and one that holds the apply button. Now I want all the info entered on this page to be shown on the next page once the apply button is clicked. However, using JSP, it doesn't help if I don't have all the fields in a single form - i.e. the form that holds the apply button. Because if I do this in the next file:

"<"%"
String name = request.getParameter ("name");
out.println ("Name: " + name);
"%">"

it doesn't work, as the form i've used for the apply button and that for the input fields is not the same.

[Edited on 10-6-2004 by AsifTheManRahman]

[Edited on 10-6-2004 by AsifTheManRahman]

Mahmood
June 10, 2004, 09:37 AM
WHy do you need separate forms? Whats wrong with all being in the same form?

Also, if you have to have separate forms, just create some hidden fields in the last form. Then on submit of that from, call a javascript which will assign the other form fields value to the hidden field. And in the next page, you call these hidden fields to see the values.

Mahmood
June 10, 2004, 09:39 AM
<form action="next page name" enctype="multipart/form-data" method="post">
<table>
<tr><td> Name: </td><td><input type = "text" name="name"></td></tr>
<tr><td> Email: </td><td><input type = "text" name="email"></td></tr>
<tr><td>Enter resume here</td><td>
<input type="file" name="upload"></td></tr>
<tr><td><input type = "submit" value = "Apply"></td><td></td></tr>

</table>
</form>

Here, on the next page, you can get each field as...

name, email and upload.

The code looks like this...
<XMP><form action="next page name" enctype="multipart/form-data" method="post"><table><tr><td> Name: </td><td><input type = "text" name="name"></td></tr><tr><td> Email: </td><td><input type = "text" name="email"></td></tr><tr><td>Enter resume here</td><td> <input type="file" name="upload"></td></tr><tr><td><input type = "submit" value = "Apply"></td><td></td></tr>
</table></form></XMP>

[Edited on 10-6-2004 by Rajputro]

AsifTheManRahman
June 10, 2004, 02:17 PM
Thanks a lot.