can u post your form?
Is the selection of add or edit client side?
CJ
Main Topics
Browse All TopicsI have a form that the user can add or edit criteria. I would like the cursor to be in a certain input field when the focus is on adding or editing. How can I do this?
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here is the portion of my form that I am talking about.
<cfif can_edit>
<table width="100%" border="1" bordercolor="##669955" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td valign="top">
<table>
<tr><td><strong>Address:</
<tr><td><input type="text" value="#address#" name="address" style="width:280px"></td><
<tr><td><input type="text" value="#address2#" name="address2" style="width:280px"></td><
<tr><td><input type="text" value="#city#" name="city" style="width:150px">, <input type="text" value="#state#" name="state" style="width:30px"> <input type="text" value="#zip#" name="zip" style="width:45px">-<input
</table>
</td>
<td valign="top">
<table>
<tr><td width="125"><strong>Teleph
<tr><td>
<table><tr>
<td><input type="text" value="#areacode#" name="areacode" style="width:30px" size="3" maxlength="3"
onClick="this.value='';" onKeyUp="if(this.value.len
<td><input type="text" value="#prefix#" name="prefix" style="width:30px" size="3" maxlength="3"
onClick="this.value='';" onKeyUp="if(this.value.len
<td><input type="text" value="#number#" name="number" style="width:50px" size="4" maxlength="4"
onClick="this.value='';" onFocus="this.value='';"><
</tr></table>
</td></tr>
</table>
</td>
<td valign="top">
<table>
<tr><td width="125"><strong>Fax:</
<tr><td>
<table><tr>
<td><input type="text" value="#faxareacode#" name="faxareacode" style="width:30px" size="3" maxlength="3"
onClick="this.value='';" onKeyUp="if(this.value.len
<td><input type="text" value="#faxprefix#" name="faxprefix" style="width:30px" size="3" maxlength="3"
onClick="this.value='';" onKeyUp="if(this.value.len
<td><input type="text" value="#faxnumber#" name="faxnumber" style="width:50px" size="4" maxlength="4"
onClick="this.value='';" onFocus="this.value='';"><
</tr></table>
</td></tr>
</table>
</td>
<td valign="top">
<table>
<tr><td><strong>Support Systems:</strong></td></tr
<tr><td>Compease: <select name="compease" style="width:50px">
<option value="yes" <cfif #compease# eq 'yes'>selected</cfif>>Yes<
<option value="no" <cfif #compease# eq 'no'>selected</cfif>>No</o
</select></td></tr>
<tr><td>Performease: <select name="performease" style="width:50px">
<option value="yes" <cfif #compease# eq 'yes'>selected</cfif>>Yes<
<option value="no" <cfif #compease# eq 'no'>selected</cfif>>No</o
</select></td></tr>
</table>
</td>
</tr>
</table>
<cfelse>
<table width="100%" border="1" bordercolor="##669955" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td valign="top">
<table>
<tr><td><strong>Address:</
<tr><td>#address#</td></tr
<tr><td>#address2#</td></t
<tr><td>#city#<cfif #city# neq "">, #state# #zip#<cfif #zip2# neq "">-#zip2#<cfelse></cfif><
</table>
</td>
<td valign="top">
<table>
<tr><td width="125"><strong>Teleph
<tr><td>#areacode#-#prefix
</table>
</td>
<td valign="top">
<table>
<tr><td width="125"><strong>Fax:</
<tr><td>#faxareacode#-#fax
</table>
</td>
<td valign="top">
<table>
<tr><td><strong>Support Systems:</strong></td></tr
<tr><td>Compease: #compease#</td></tr>
<tr><td>Performease: #performease#</td></tr>
</table>
</td>
</tr>
</table>
</cfif>
I have not had any prior programming experience and have been working with coldfusion for about 6 months. I am trying to put together a web site and I do so much by trial and error. The reason I use the two forms is because that is how I got it to do what I wanted. If there is a better way please share. do I need to change what you provided to be
<body onload="documnet.accountfo
I replaced forms with accountform(the name of my form), do I need to replace element with anything?
I did try this and it seems to work. it is a variation of what you posted earlier.
<cfif can_edit>
<script language="JavaScript">
document.accountform.addre
</script>
<cfelseif can_editcontact>
<script language="JavaScript">
document.accountform.first
</script>
<cfelseif can_addcontact>
<script language="JavaScript">
document.accountform.first
</script>
</cfif>
typo
<body onload="documnet.accountfo
should have been elements, but the above will only set the focust on the first form element
>>I have not had any prior programming experience and have been working with coldfusion for about 6 months
been there ... and still learning
>>I do so much by trial and error
been there too... wish i had forund EE from the begining, would have made things so much easier
i did this in asp and it woked fine, should be transferable to CF
pseudocode - for a members page
run query
select*
from memebers
if url.memberid
where id= url.memberid
else
where id= null // if memeber.id is pk then no member will have a a null id
create form
if query has a record set edit=true else edit =false
output query to populate form fields
let user add/ edit as required, validate as necessary
submit form
on action page
if edit
update query
else
insert query
process as required
Business Accounts
Answer for Membership
by: Jester_48Posted on 2003-11-12 at 07:30:33ID: 9732033
if you have a variable to determin the status: add/edit
s();
.focus();
<script>
function thisOnLoad(){
<cfif var eq 'edit'>
document.form.element.focu
<cfelseif var eq 'add'>
document.form.otherElement
</cfif>
}
</script>