Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Populate textbox in datagrid from custom keypad popup window


Message #1 by "Sean Marchiafava" <smarch@c...> on Thu, 18 Jul 2002 15:03:27
You may insert either of the 2 JavaScript functions below into your 
aspx/html page to change the Text of your target control.
Then call this function from your popup window like this:
<input type=button value="Return" onclick="opener.getTextBox
('txtEdit1').value='pig head'">
<input type=button value="Return" onclick="opener.setTextBoxValue
('txtEdit1','dogmeat')">



<script language="JavaScript">
<!--
function getTextBox(controlid) {
  var elem
  for(i=0;i<document.forms[0].elements.length;i++) {
    elem=document.forms[0].elements[i]
    if (elem.name.indexOf(controlid)!=-1) {
      return elem
    }
  }
}

//-->
</script>


<script language="JavaScript">
<!--
function setTextBoxValue(controlid, newvalue) {
  var elem
  for(i=0;i<document.forms[0].elements.length;i++) {
    elem=document.forms[0].elements[i]
    if (elem.name.indexOf(controlid)!=-1) {
      elem.value=newvalue //set the value of the control
      return true //stops the loop
    }
  }
}

//-->
</script>


Similar threads:
aspx thread: setting focus on a textbox in a datalist in an 
edititemtemplate 
http://p2p.wrox.com/view.asp?list=aspx&id=195254



Previous message:
> That's excellent, that will attach a javascript function to the button 
in the grid.  How about the return value from the popup window, how do I 
assign this return value from popup to the buttons associated textbox?  
Especially when its deep within grid.  I would assume I need to send the 
textbox's id and container information back to properly find and assign 
the value on return.

  Return to Index