I'm still getting the same errors

Here's the code (html generated from CF)

The size of the form is dictated by a cfoutput query.

<script>
        var i = null;
        var compName = null;
        var clid = null;
        function clientRecPop(i) {
                clid = document.forms.clientSearch.client_id[i];
                compName = document.forms.clientSearch.company[i];
                self.opener.document.forms.NewJob.clientID.value = clid;
                self.opener.document.forms.newJob.coName.value = compName;
                
        
                
                //window.close()
}

</script>
</head>

<body id="clientSearch">
<table width="100%" border="0" cellpadding="0">
  <tr bgcolor="#CCCCCC">

    <td><span class="style5">*</span></td>
    <td><span class="style5">Client #</span></td>
    <td><span class="style5">Client Company Name</span></td>
    <td><span class="style5">Contact Name</span></td>
    <td><span class="style5">Phone#</span></td>
    <td>&nbsp;</td>

  </tr>
  <form action="" method="post" name="clientSearch" id="clientSearch">
  
  <tr>
    <td><input name="Status1" type="text" value="A" size="2">
    </td>
    <td><input name="client_id1" type="text" value="158903" size="10"></td>
    <td><input name="company1" type="text" value="Wal-Mart Stores, Inc          
          "></td>
    <td><input name="contact1" type="text" value="Mohsen Ghadimkhani            
           "></td>
    <td><input name="phone1" type="text" value="" size="10"></td>

    <td><input name="recID1" type="button" onClick="clientRecPop(1)" 
value="Select"></td>
  </tr>
 
  <tr>
    <td><input name="Status2" type="text" value="A" size="2">
    </td>
    <td><input name="client_id2" type="text" value="158904" size="10"></td>
    <td><input name="company2" type="text" value="Wal-Mart Stores, Inc.         
          "></td>
    <td><input name="contact2" type="text" value="Wayne Cox                     
           "></td>
    <td><input name="phone2" type="text" value="" size="10"></td>

    <td><input name="recID2" type="button" onClick="clientRecPop(2)" 
value="Select"></td>
  </tr>

Scott A. Stewart, 
Web Application Developer
 
Engineering Consulting Services, Ltd. (ECS)
14026 Thunderbolt Place, Suite 300
Chantilly, VA 20151
Phone: (703) 995-1737
Fax: (703) 834-5527


-----Original Message-----
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 10, 2005 02:56 pm
To: CF-Talk
Subject: Re: Dynamic Javascript Question
Importance: Low

> I�m hacking at Javascript, what this script is supposed to
> do is pass form values back to another form (click on a
> button, select a record, and the record data is posted
> back to the previous form etc.). The selection form is
> based on a query, so it�ll change based on how many
> records it returns.

You really ought to name your form in the parent document rather than
using forms[0] which is liable to bite you in the ass later.

<form name="specialformname">
self.opener.document.forms.specialformname.clientID.value = clid;

You're missing { and } around your loop code... and you should add
semicolons to each line -- intepreters allow you to get away with not
including the semicolon, but that's sloppy. The variables compName and
clid should be declared with the var keyword... so should the variable
i. It's the same as ColdFusion functions -- it'll bite you in the ass
later if you don't.

var compName = null;
var clid = null;

for (var i=1; i<<cfoutput>#qry_getClient.recordcount#</cfoutput>;i++)
{
  clid = document.clientSearch.client_id[i].value;
  compName = document.clientSearch.company[i].value;
  self.opener.document.forms.myform.clientID.value = clid;
  self.opener.document.forms.myform.coName.value = compName;
}

More importantly I don't think this function will do what you want...

Unless what you want is to set the value of a single company and
clientID input elements in the parent window several times in rapid
succession before finally bringing them to rest with a single value.
:P In other words, this code would produce the same end-result as if
you had removed the loop all-together and simply set the value of "i"
to #qry_getClient.recordcount# and only populate the form with the
values from the last record. So if you want to get the values from an
item in the list by using links in the list to determine which item
was selected, you want to add an argument or two to your function. Try
this:

function clientRecPop(i) {
  var compName = null;
  var clid = null;

  clid = document.clientSearch.client_id[i].value;
  compName = document.clientSearch.company[i].value;
  self.opener.document.forms.myform.clientID.value = clid;
  self.opener.document.forms.myform.coName.value = compName;
}

The error you're getting specifically has nothing to do with these
problems btw... it can't find your "clientSearch.client_id" object,
either because you left out the word "form" or mis-spelled the form
name or some other reason... you might try
document.forms.clientSearch.client_id

hth


s. isaac dealey   954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206259
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to