thanks for your details response.
following coding will use at the time of data insert.
same like this, if we have to update the same records.
how can update the record by radio button.
if purchase type company radio button should checked
if purchase type client radio button should checked
if purchase type contractno text box should active and retrieve the
value in text box
<%
rec_id=Request.QueryString("rec_id")
ssql="select rec_id,software,sftwr_key,version,sofcd,manuf,vend or,ptype,pdate,sno,nlice,location,maint,madate,lsn ame,note from softwarelist3 where rec_id='"& rec_id &"'"
set rs=cn.Execute(ssql)
if rs.eof=false then
%>
<INPUT id=radio1 type=radio name=radio1 value="<%Response.Write(rs("purchasetype"))%>" <%if purchaseType="parson" then response.write("checked")%> >company
<INPUT id=radio1 type=radio name=radio1 value="<%Response.Write(rs("purchasetype"))%>" <%if purchaseType="client" then response.write("checked")%> >client
<INPUT id=radio1 type=radio name=radio1 value="" <%if purchaseType="" then response.write("checked")%> >Client contractor No<input type=text id=text1 name=radio1 value="<%Response.Write(rs("ptype"))%>"
<%
end if
%>
it always retrieve value in text box and contractno radio button checked
if purchasetype company it donât check company radio button checked
if purchasetype client it donât check client radio button checked
regards.
Quote:
quote:Originally posted by planoie
First, I want to point out that you shouldn't have a textbox with the same name as the radio buttons.
Let's look at the ASP side of this...
When you draw your radio buttons, you can check the database value for the purchase type and fill in the right checkbox "checked" property to check it. Here's how the radio buttons would look...
<% purchaseType = <value from database> %>
<INPUT id=radio1 type=radio name=radio1 value="parson" <%if purchaseType="parson" then response.write("checked")%> >company
<INPUT id=radio1 type=radio name=radio1 value="client" <%if purchaseType="client" then response.write("checked")%> >client
<INPUT id=radio1 type=radio name=radio1 value="" <%if purchaseType="" then response.write("checked")%> >Client contractor No
That's what you can use to select the right radio button.
To disable a radio button, you need to modify the enabled property. For example:
<INPUT id=radio1 type=radio name=radio1 value="" enabled="false">
This disables the radiobutton. The same applies to a textbox. If you need to do this based on some value from the ASP code, you can wrap those inside of an ASP If just as shown above for "checked".
As far as the user interaction is concerned, you'll need to check the values and checked status of the various controls in JavaScript when the user clicks or types.
To disable the textbox when the radio buttons are clicked, you can use the radio button "onclick" event handler. For your example, I'd doing something like this:
<INPUT id=radio1 type=radio name=radio1 value="parson" onclick="this.form.theTextBox.enabled=false;">comp any
<INPUT id=radio1 type=radio name=radio1 value="client" onclick="this.form.theTextBox.enabled=false;">clie nt
<INPUT id=radio1 type=radio name=radio1 value="" onclick="this.form.theTextBox.enabled=true;">
If you want to disable the non-applicable radio buttons when someone enters a value into the text box (for the third radio button), you could do something like this (note that this handles the case where the user deletes the whole value, thus re-enabling the other checkboxes as well as selecting the correct checkbox):
<input type="text" name="theTextBox" onclick="this.form.radio1[2].checked=true;" onKeyUp="this.form.radio1[0].enabled=(this.value=='');this.form.radio1[1].enabled=(this.value=='');">
What this is doing is first selected the third radio button when you click in the textbox, and then testing the textbox value to see if it's blank when you press a key to enter a value. That test evaluates to a true or false, and this sets the enabled state of the two first radio buttons. Radio buttons of the same name get put into an array in the browser document object so you have to refer to them by an array index of the control name (radio1[x]).
Hopefully this helps.
Peter
------------------------------------------------------
Work smarter, not harder.
|