Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Jscript: Oncheck value appears: parent vs iframe

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-01-29 : 06:23:24
hello,
I need assistance on this java script function.

i have the following code in an inline frame

On check, the value appears in the textarea, in the inline frame. How do i get the value to appear in the parent window textarea ?

thanks


INLINE FRAME CODE

<script>
function boxClicked(o) {
var total = "", count = 0;
var form = o.form;
// use the checkbox name from html above
var boxes = form["box"];
for(var i = 0; i < boxes.length; i++) {
if(boxes[i].checked) {
total += boxes[i].value + " ";
count++;
}
}
form.total.value = total;
form.count.value = count;
}
</script>



CODE IN TEXT AREA, In the inline frame. However i would want to the value written to the text area not in the inline frame, but written to the parent window

[CODE]
<form method="POST" action="index.asp" name="test">
<!-- all boxes must have the same name -->
<input name=box type="checkbox" onClick="boxClicked(this)" value="xyz">
<input name=box type="checkbox" onClick="boxClicked(this)" value="abc">
<input name=box type="checkbox" onClick="boxClicked(this)" value="123">
[/CODE]

Any assisntance please ?

Afrika

Kristen
Test

22859 Posts

Posted - 2006-01-29 : 06:47:46
window.opener.something ??

Kristen
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-01-29 : 06:52:58
No Sir
i tried adding this but it still dont work


}

form.total.value = total;
form.count.value = count;
parent.document.getElementById("total").value = total;
}
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-01-29 : 06:59:52
Line 3: This is writing the value to a blank area in the parent, but i want to write to the textbox ?

any advice

}

form.total.value = total;
form.count.value = count;
parent.document.getElementsByTagName('body')[0].appendChild(document.createTextNode(total));
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-01-29 : 09:37:43
Finally got it to work, phew... Am not really a jscript guy though.

parent.document.getElementById('total').value = total;

and changed the ID of the textarea
Go to Top of Page
   

- Advertisement -