Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS - Pass Value from Child to Parent 1

Status
Not open for further replies.

sgkdnay

Technical User
Aug 4, 2008
21
Im driving myself nuts for the past 2 days. Tried everything to fix this, even tweaking, still no go. Might have overlooked a thing or 2...

Originally (both using Element ID (not Name)):
On Parent Windows - Form Called (NewCRM) and TextArea called (NoteAdd)
On Child Windows - Form Called (NewCRMN) and TextArea called (AmendNote)

<script type="text/javascript">
function AddN(Str){
var NoteA2 = document.getElementById("amendnote").value;
document.getElementById("noteadd").value += NoteA2;
}
</script>
To submit, I put <input type=button onclick="AddN('Amend Note');"> It gave me a return of "Amend Note" on the parent (NoteAdd), so i figure it works well.

But I wanted to "copy" the child's TextArea, so I change AddN() in the function screen and onclick="AddN();" in the submit, only this time, it gave me "undefined" in the parent textarea.

What gives? Hope its a minor thing I've overlooked. I do well on VB, but rusty on Javascript.

Thanks
 
Several issues. You should respect case. If its AmendNote, it should be document.getElementById('AmendNote').value. Next, you accept a parameter, Str, but don't use it. Based on your example, you make it sound like it was being used. Are you sure what you posted is an accurate description of your problem?

-----------------------------------------
I cannot be bought. Find leasing information at
 
[tt]function AddN(){
var NoteA2 = document.getElementById("amendnote").value;
[blue]if (window.opener && !window.opener.closed) {[/blue]
window.opener.document.getElementById("noteadd").value += NoteA2;
//do some thing such as closing out
[blue]} else {
//do some other thing as well such as alert or close out
}[/blue]
}[/tt]
 
jax:
I apologized for the case sensitive char, its all lower case in the parameters.

I changed AddN to AddNo, this time in Firefox no error but no result, in IE it gave me error: Object Expected

tsuji:
I tried your method, still gives me 'undefined'.

Thanks
 
The textarea in the parent has id="noteadd", in the child has id="amendnote" all case sensitive. If you've changed anything, it won't need me to tell what to do, I suppose? The parent-child relation is established via window.open()? Those are the conditions they've to meet.
 
tsuji:
Yes you're correct, all lowercase and set as it was supposed to function but gives me 'undefined'. The pop-up is windowless modal (similar to VB) but using JS/Ajax. The (name).Open is crm=DHTMLWindows.open(parameter).

Sort of "windows in a windows", not an IFRAME or New Windows PopUp in a way.

Hope this help clarify more?

Thanks
 
Any other idea that could help this issue?

Other another path should be taken to defeat this purpose?

Thanks
 
Perhaps giving us the details that it was not really a child/parent relationship in the first post would have gleaned more help, as it's only now after many suggestions you tell us it's really just a DHTML 'window'.

Now you go on to mention 'DHTMLWindows' which we know nothing about.

Perhaps a URL [!]and any more relevant details[/!] would be your best bet of getting help?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
the code is a bit long, i set it on web for you to check if you like. 3 parts of files:

(it normally goes into dhtml folder.

The actual website is for action, but no 'real' data on it yet, its all layout work up until its done, then live data will load into that, that part is easy for me, but layout is what's giving me headache/functionality :D

Thanks
 
I haven't looked at your sites; but given your additional statement on the popup, you have to put all the function _inline_: that's the only way you can use "ajax" content type (funny that they get natural high with word rather than deed).

><input type=button onclick="AddN('Amend Note');">
[tt]<input type=button onclick="
var NoteA2 = document.getElementById('amendnote').value;
document.getElementById('noteadd').value += NoteA2;
">[/tt]
 
Tried your suggestion, funny thing... it works..

Thanks a bunch for helping solve this :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top