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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically checking checkbox with onFocus textfield

Status
Not open for further replies.

bamboo

Programmer
Aug 22, 2001
89
US
I have a series of checkboxes and an input text field next to each one. I have a js search pop-up window that opens when a user clicks in the text field. This works fine, however I would also like the checkbox next to it to automatically be checked at the same time. The pop-up works fine, however I'm not sure how to also dynamically check the box the same time the pop-up window opens.

Here is just one of the checkbox/text fields:

<input type="checkbox" name="part_Ops" value="1">
<input type="text" name="part_Name" onFocus="jsPopupWindow('frmSet_search_for_name.cfm?nameField=ispart_OpsName&frmName=frmParties&nextField=part_EHD','part_EHD')">

Here's the js that pops-up the search window:

<script language="javascript">
function jsPopupWindow(url,nextField) {
//alert(url);
var popupWindow;

if (document.all)
var xMax = screen.width, yMax =
screen.height;
else
if (document.layers)
var xMax = window.outerWidth,
yMax = window.outerHeight;
else
var xMax = 640, yMax=480;

var xOffset = (xMax - 250)/2, yOffset = (yMax - 250)/2;

if (url ==
"frmSet_search_for_name.cfm?nameField=ispart_OpsName&frmName=frmParties&
nextField=part_EHD") {

document.frmParties.part_Ops.checked=true && document.frmParties.part_EHD.focus();
}

popupWindow = window.open(url, "popupWindow", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,height=450,width=770
,screenX='+xOffset+',screenY='+yOffset+',
top='+yOffset+',left='+xOffset+'");
popupWindow.focus();

}



 
What does this mean?
Code:
document.frmParties.part_Ops.checked=true && document.frmParties.part_EHD.focus();
 
My apologies. It should just be:

if (url ==
"frmSet_search_for_name.cfm?nameField=ispart_OpsName&frmName=frmParties&
nextField=part_EHD") {document.frmParties.part_EHD.focus();
}

So the code here is working fine. I just need to know what I need to adjust/add to also make the checkbox be checked.
 
try this

Code:
onFocus="this.previousSibling.checked=true;jsPopupWindow('frmSet_search_for_name.cfm?nameField=ispart_OpsName&frmName=frmParties&nextField=part_EHD','part_EHD')"


Kate

[small]"The Distorted View"
-the only podcast that's fresh perked
www.distortedview.com[/small]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top