got4a wrote:
Now, I need to write .htm or .asp (2.htm or 2.asp) that will have a
textbox and submit button. When user clicks on submit two things have
to happen:
1) 1.asp opens in new browser window
2) textbox in 1.asp gets populated with textbox value from 2.htm (or
2.asp)
It may sound like piece of cake, but it's turned into a problem for me.
Any help would be appreciated.
as I understood the two forms (1.asp and 2.htm)
are exactly same (except button to send infos to 1.asp)
function pop() {
if(!(!truc) || !truc.closed) truc.close();
truc=window.open('1.asp','','width=300,height=250' );
txfer();
}
function txfer() { // copy content of each textbox from 2 to 1
var a = document.forms[0].elements;
var b = truc.document.forms[0].elements;
for(var i=0;i<b.length;i++) if(a[i].type=='text') b[i].value=a[i].value;
}
in file '2.htm' :
<input type=button onclick="pop();"
value="Open Pop-Up and Transfer Datas">
</form>
or with your case (only 1 textbox + 1 submit button)
file '2.htm' :
<html>
<script type="text/javascript">
function pop() {
var a = document.forms[0].elements[0];
if(a.value.length<1) {
alert('Fill the field of text')
a.focus(); a.select();
}
else {
if(!(!truc) || !truc.closed) truc.close();
truc=window.open('1.asp','','width=300,height=250' );
var b = truc.document.forms[0].elements[0];
b.value = a.value;
alert('that\'s done');
}
}
</script>
<form onsubmit="pop();return false;">
Name : <input type="text">
<input type="submit" value="OK">
</form>
</html>
--
Stephane Moriaux et son [moins] vieux Mac