Script Categories













Forms >>> Form Target Formatting.

Allows you to format the target window of a form from the form's target property. This allows for the use of window properties, variables, and other data manipulation to effect these options.

Name:
Email:
Favorite Color:

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
// test variables
var myHeight = 200;
var isResizable = true;

function createTarget(form) {
_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
}
else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i < _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
   }
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}
//  End -->
</script>
<!-- Special Notes:  -->
<!-- Simply begin the target attribute with a name of your -->
<!-- choice, _blank, _top, etc... followed by a colon and -->
<!-- the window options string used in the window.open -->
<!-- command. Anything in this string enclosed in { and } -->
<!-- will be interpreted as JavaScript. -->

<form action="YOUR-CGI-SCRIPT.CGI" method=get
target="foobar:width={window.screen.width/2},
         height={myHeight},
         scrollbars,
         {(isResizable)?'resizable':''},
         status"
onSubmit="return createTarget(this);">
<table>
<tr><td
align=right>Name:</td>
<td>
<input name=name></td></tr>
<tr><td
align=right>Email:</td>
<td>
<input name=email></td></tr>
<tr><td
align=right>Favorite Color:</td>
<td>
<input name=fav_color></td></tr>
<tr><td
align=center colspan=2><input type="Submit"></td></tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©