Problem with onclick() event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ze colmeia
    New Member
    • Oct 2006
    • 8

    Problem with onclick() event

    Hi all,

    I have a little javascript function that assigns the value from a parent window to a field on a iframe. The function is on the parent page and its called by a button onclick() event on the other page. It works fine the first time i click on the button but if i click again the value isn't assigned anymore.

    This is the function on the parent page:
    Code:
    <SCRIPT language=javascript>
    
    function Id(){
    	var id = frm1.PersonId.value;
    	return id;
    }
    
    </SCRIPT>
    This is how its called on the other page:

    Code:
    <BUTTON class=MsoNavAddNew id=addRecord onclick=PersonId.value=parent.Id(); MsoTextAlign="General"></BUTTON>
    I thought an onclick() event would always work when called but perhaps not :(

    Any ideias about this? Thanks in advance!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You need to refer to elements properly. Is frm1 defined properly somewhere? If not use document.forms["frm1"] to refer to the form.

    Again, in the case of the onclick code, you could change it to something like:
    [html]<BUTTON class="MsoNavAd dNew" id="addRecord" onclick="this.f orm.PersonId.va lue=parent.Id() ;" MsoTextAlign="G eneral"></BUTTON>[/html]

    Comment

    Working...