Computing.Net > Forums > Web Development > Javascript: Cross input via link

Javascript: Cross input via link

Reply to Message Icon

Original Message
Name: mie2com
Date: December 2, 2006 at 23:28:04 Pacific
Subject: Javascript: Cross input via link
OS: WinXP
CPU/Ram: Pentium III
Model/Manufacturer: Sony
Comment:

What is wrong with this script. It did not pass the value to input. Basically, what i am trying to do is this:

In index page, there is a link(link#1) and an input. And, when I click link#1, there will be a pop up window which contain link#2. And when I click link#2, it will pass a value to input in index page, and the popup will close. Here's the script.

*For index.html;

<html>
<head>
<script type="text/javascript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400px,height=500px,left = 312,top = -16');");
}
</script>
</head>
<body>
<form name="formname">
<input id="font_type" type="text" name="font_type">
[a href="javascript:void()" onclick="javascript:popUp('pop.html')"]Font[/a] <-- I have to use [a] to avoid the forum to post it as a link.
</form>
</body>
</html>

*For pop.html:

<html>
<head>
<title></title>
<script type="text/javascript">
function font() {
document.formname.font_type.value = "Arial";
}
</script>
</head>
<body>
[a href="javascript:void()" onclick="font();window.close();"]
Arial
[/a]
</body>
</html>



Report Offensive Message For Removal


Response Number 1
Name: mie2com
Date: December 3, 2006 at 06:02:55 Pacific
Subject: Javascript: Cross input via link
Reply: (edit)

I found the solution. Changes to be made is in pop.html;

[a href="javascript:opener.document.formname.font_type.value='Arial';self.close();"]
Arial
[/a] <--Assuming [a] is <a> to avoid this message board to post it as a link.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Javascript: Cross input via link

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software