By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

Populate textbox in new window

P: n/a
Hi guys,
Lots of threads and ideas, but I couldn't find what I'm looking for.
Hence, this.

I have asp page (say, 1.asp) that has a textbox. This page is available
to me in read-only mode, meaning I know all the field names, functions
names etc., but can't change anything.

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.

Aug 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ASM
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
Aug 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.