/    Sign up×
Community /Pin to ProfileBookmark

autogenerate text box during passing value from child window?

can i do script like.

when i click the edit button at the parent window(page.pgp), a window popup( anotherpage.php )

when i enter a value there, then it appears inside parent window’s text box1

then when i enter another value at the children window, then at the parent window textbox2 will appear and with my second value inside

if i insert 3rd value, another textbox appear with my 3rd value inside in the parent window …

i hope it can auto generate text box , depends on how many value i insert in the child window ..

possible?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 09.2004 — The basics:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Parent page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
//<![CDATA[
<!--
function OpenWin() {
var content='<form action="#" name="childform">'+
'<input type="text" id="newtext" /><br />'+
'<button type="text" onclick="opener.InsertField(document.getElementById("newtext").value);">Add field</button>'+
'</form>';
ChildWindow=window.open("", "newwin");
ChildWindow.document.write(content);
ChildWindow.document.close();
}
var idx=0;
function InsertField(text) {
var newField=document.createElement('input');
newField.setAttribute('id','newField'+(idx++));
newField.setAttribute('type','text');
newField.setAttribute("value", text);
document.getElementById('myform').appendChild(newField);
}
//-->
//]]>
</script>

</head>
<body>
<form action="#" id="myform">
<button type="text" onclick="OpenWin();">edit</button>
<button type="submit">submit</button>
</form>
</body>
</html>
Copy linkTweet thisAlerts:
@ltingauthorJan 09.2004 — i ccopy the script ..

and try to run it .. but browser said runtime errors ...
Copy linkTweet thisAlerts:
@PittimannJan 09.2004 — Hi!

There's a tiny mistake in the line with the content variable.

Please try it like this:

var content='<form action="#" name="childform">'+'<input type="text" id="newtext" /><br />'+'<button type="text" onclick="opener.InsertField(document.getElementById('newtext').value);">Add field</button>'+'</form>';

Cheers - Pit
Copy linkTweet thisAlerts:
@FangJan 09.2004 — I used extended characters, which were ofcourse changed in the output :rolleyes:
×

Success!

Help @lting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...