Forum Moderators: open

Message Too Old, No Replies

XHTML, onsubmit and Target?

         

bitstearm

4:37 am on Jan 29, 2003 (gmt 0)

10+ Year Member



Hi,

Since the target attribute is not allowed in XHTML 1.0 strict I'm wondering how one can direct the results of a Form submit to a new window instead of "self". Consider the follwing

<form id="Login" action="someurl" onsubmit = "window.open('someurl', 'newwin')" target = "newwin" method="post" enctype="multipart/form-data">

How can one rewrite this in XHTML 1.0 strict?

Many thanks!

DrDoc

4:47 am on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the action attribute ..

And use a javascript function to open the window:

<script type="text/javascript">
function myFunc(){
input_name = document.getElementById('name').value;
input_blah = document.getElementById('blah').value;
window.open("somescript.cgi?name="+input_name+"&blah="+input_blah,"newwindow")}
</script>

<form onsubmit="myFunc()">
<input type="text" id="name" />
<input type="text" id="blah" />
</form>

bitstearm

5:04 am on Jan 29, 2003 (gmt 0)

10+ Year Member



Yes, I guess that will work. Is there another way that does not involve cgi? I'd like to keep this as self contained and simple as possible.

Why oh why did they have to remove target? :)

DrDoc

7:39 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They removed
target
because Strict does not allow the use of frames, hence, no need for the target attribute.

But, if you really need to use target, why not use a different DTD?

Anyway, the cgi was just an example .. I don't know what your url is, or the file type .. but you need to apss the arguments to the file either way, and yes .. if you're doing it through a script, there's no way to do it without the ? .. so it'll be using GET instead of POST.

bitstearm

11:53 pm on Jan 29, 2003 (gmt 0)

10+ Year Member



Thanks so much for your input. With this site revision I decided to start a new and better life by coding to the strictest possible standard, hence the choice of Strict :) I may have to make some exceptions to that rule and use transitional for pages that rely on target. I wrote a server side script last night that processes data from the Javascript you suggested, so I can make it work both ways.

Thanks again.