let say i use for loop to display the record from database/// and each line of records has a checkbox ..
in a row.. if let say one of the column does not fulfill the requriement !! don allow it to check the checkbox...
e.g. if let say rsLook.Fields("Supp_Email") = "" then
don allow it to check
how can i do that ?
16 1496
Heya, lyealain.
Let's have a look at your code. It may be more practical to do this server-side.
Changed thread title to better describe the problem (did you know that threads whose titles contain fewer than three words actually get FEWER responses?).
- <head>
-
<link rel="stylesheet" type="text/css" href="../Styles.css">
-
-
<script type="text/javascript">
-
-
function validate(form)
-
{
-
var isChecked = false;
-
for(i=0;i<document.frmSend[0].chkSupplier.length;i++)
-
{
-
if(document.frmSend[0].chkSupplier[i].checked)
-
isChecked = true;
-
}
-
if(!isChecked) alert("Check it!!!");
-
}
-
-
</script>
-
-
</head>
- Response.Write("<form name='frmSend' method='post' action='sendSupplier.asp' onsubmit='return validate(this)' >")
-
-
Call ReportA()
-
-
Response.write("<table width='900' cellspacing='2' cellpadding='0'><tr><td align='right'><input type=submit name=updAction value='SUBMIT'> </td></tr></table>")
-
-
Response.Write("</form>")
-
-
End Function
-
%>
-
-
<%
-
Function ReportA()
-
-
Response.write("<tr bgcolor='" &color& "'>")
-
response.write("<td><font class='rec'>" &intRecNo& "</font></td>")
-
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("PartNumber")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("PartDesc")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("comCode")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("MPN")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("QMPN")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("AML")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("SupplierName")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("LeadTime")& "</font></td>")
-
-
-
-
If CheckAll = "checked" Then
-
response.write("<td><input type='checkbox' name='chkSupplier" &count& "' checked value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
Else
-
response.write("<td><input type='checkbox' name='chkSupplier" &count& "' value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
End If
-
Response.write("</tr>")
-
End Function
-
%>
i only able to validate if all the checkbox are not checked// then show error..
Heya, lyealain.
Here's how I would handle that situation. Instead of using JavaScript, have your ASP code check the value of the field, and if it is empty, set the disabled property of the checkbox.
E.g., -
if rsReport.Fields("SupplierName") = "" then
-
Response.Write("disabled=\"disabled\"/></td>");
-
else
-
Response.Write("/></td>");
-
end if
-
Heya, lyealain.
Here's how I would handle that situation. Instead of using JavaScript, have your ASP code check the value of the field, and if it is empty, set the disabled property of the checkbox.
E.g., -
if rsReport.Fields("SupplierName") = "" then
-
Response.Write("disabled=\"disabled\"/></td>");
-
else
-
Response.Write("/></td>");
-
end if
-
i did this.. - if rsLook.Fields("Supp_Email") = "" then
-
-
dim strCBstate
-
strCBstate = "disabled"
-
else
-
strCBstate = ""
-
end if
-
-
If CheckAll = "checked" Then
-
response.write("<td><input type='checkbox' strCBstate name='chkSupplier" &count& "' checked value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
Else
-
-
response.write("<td><input type='checkbox' strCBstate name='chkSupplier" &count& "' value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
End If
but i cant make it disable....
Heya, lyealain.
Thanks for using CODE tags! Did you know that you can specify a language for your CODE tags to make your source code easier to read?
You will still need to use [/code] to close your code blocks, regardless of the language, but you can the use one of these tags to open your code block:
[code=html]
[code=javascript]
[code=asp]
and so on.
Thanks!
MODERATOR
thansk.. haha.... pls help on my question.. thanks
What's the HTML output looking like? I'm not really familiar with ASP, but it looks as though your code outputs the literal 'strCBstate' instead of the value of strCBstate.
Did you mean this instead? -
response.write("<td><input type='checkbox' " & strCBstate & " name='chkSupplier" ...
-
wat i wan is actually ... imagine that we display 10 rows from database...
each row has checkbox...
so .. i wan the system automatic hide the checkbox at the (e.g) third row if the column at third row does not fulfill the requirement
I see.
Why not simply not output the checkbox HTML for the row if the data is invalid?
I see.
Why not simply not output the checkbox HTML for the row if the data is invalid?
can but it look ugly... hahahaha... how do i make that disabled... ? thanks experrt
Fair enough.
Ok. So you've got your table cell. Now you need to be able to hide or disable the checkbox if the data is invalid.
Here are some ideas.
The first idea is to disable it.
A valid checkbox would look like this: -
<input type="checkbox" ... />
-
Whereas an invalid checkbox would look like this: -
<input type="checkbox" ... disabled="disabled" />
-
The other option is to make the checkbox invisible: -
<input type="checkbox" ... />
-
<input type="checkbox" ... style="visibility:hidden;" />
-
The latter will still take up space as if the checkbox were there, but it will be invisible and will not respond to clicks.
You have the right idea in your ASP code; if the checkbox is invalid, you output some extra attribute that makes the checkbox disabled. You just have to figure out what it is that your code is doing that it is not supposed to be doing.
Hi ,
Try this thing..
< Code: ( asp )>
if rsLook.Fields("Supp_Email") = "" then
dim strCBstate
strCBstate = "disabled"
else
strCBstate = ""
end if
If CheckAll = "checked" Then
response.write("<td><input type='checkbox' disabled=\"" + strCBstate + "\" name='chkSupplier" &count& "' checked value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
Else
response.write("<td><input type='checkbox' disabled=\"" + strCBstate + "\" name='chkSupplier" &count& "' value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
End If
</Code>
actually u have to pass the value to 'disabled' attribute
thanks for reply... i think the bold one should be written like this disabled=""\ + strCBstate + \"" ????
BUT now it disabled everything... even those with the email exist...hahahhaaah.
if put disabled=""\ + strCBstate + "\" got error
here is my complete code..!!! - dim strCBstate
-
if rsLook.Fields("Supp_Email") = "" then
-
className= "recHighlight"
-
href = "<b>"
-
endhref = "</b>"
-
strCBstate = "disabled"
-
-
elseif rsLook.Fields("week1") = "" then
-
className= "pageLink1"
-
strCBstate = "disabled"
-
-
else
-
strCBstate = ""
-
className = "pagelink"
-
href = ""
-
Endhref =""
-
end if
-
<%
-
Function ReportA()
-
-
Response.write("<tr bgcolor='" &color& "'>")
-
response.write("<td><font class='rec'>" &intRecNo& "</font></td>")
-
-
Response.Write("<td><font class='pageblue'>" &rsReport.Fields("PartNumber")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("PartDesc")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("comCode")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("MPN")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("QMPN")& "</font></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("AML")& "</font></td>")
-
Response.Write("<td>"&href&"<a href= '/CLS1/CLSsendmail/Sourcing/CheckSuppEmail.asp?supp="&rsReport.Fields("SupplierName")&"&rfq="&rfq&"&rt="&RequestTime& "&DateNow="&DateNow&"'><font class='"&className&"'><u>" &rsReport.Fields("SupplierName")& "</font></a></u></td>")
-
Response.Write("<td><font class='rec'>" &rsReport.Fields("LeadTime")& "</font>"&endhref&"</td>")
-
-
-
-
If CheckAll = "checked" Then
-
response.write("<td><input type='checkbox' disabled=""\ + strCBstate + \"" name='chkSupplier" &count& "' checked value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
Else
-
response.write("<td><input type='checkbox' disabled=""\ + strCBstate + \"" name='chkSupplier" &count& "' value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
-
End If
-
Response.write("</tr>")
-
End Function
-
%>
in my editor.. it din come out green color.. now all thecheckbox are disabled..!!!!! those with emai... also disabled
Heya, lyealain.
Make sure you set strCBState in your loop.
Also, should it be " & strCBState & " instead of " + strCBState + "?
thanks for reply... i think the bold one should be written like this disabled=""\ + strCBstate + \"" ????
BUT now it disabled everything... even those with the email exist...hahahhaaah.
if put disabled=""\ + strCBstate + "\" got error
here is my complete code..!!!
dim strCBstate
if rsLook.Fields("Supp_Email") = "" then
className= "recHighlight"
href = "<b>"
endhref = "</b>"
strCBstate = "disabled"
elseif rsLook.Fields("week1") = "" then
className= "pageLink1"
strCBstate = "disabled"
else
strCBstate = ""
className = "pagelink"
href = ""
Endhref =""
end if [/code]
[code=asp]
<%
Function ReportA()
Response.write("<tr bgcolor='" &color& "'>")
response.write("<td><font class='rec'>" &intRecNo& "</font></td>")
Response.Write("<td><font class='pageblue'>" &rsReport.Fields("PartNumber")& "</font></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("PartDesc")& "</font></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("comCode")& "</font></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("MPN")& "</font></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("QMPN")& "</font></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("AML")& "</font></td>")
Response.Write("<td>"&href&"<a href= '/CLS1/CLSsendmail/Sourcing/CheckSuppEmail.asp?supp="&rsReport.Fields("Supplie rName")&"&rfq="&rfq&"&rt="&RequestTime& "&DateNow="&DateNow&"'><font class='"&className&"'><u>" &rsReport.Fields("SupplierName")& "</font></a></u></td>")
Response.Write("<td><font class='rec'>" &rsReport.Fields("LeadTime")& "</font>"&endhref&"</td>")
If CheckAll = "checked" Then
response.write("<td><input type='checkbox' disabled=""\ + strCBstate + \"" name='chkSupplier" &count& "' checked value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
Else
response.write("<td><input type='checkbox' disabled=""\ + strCBstate + \"" name='chkSupplier" &count& "' value='" &rsReport.Fields("PartNumber")& "/"&rsReport.Fields("PartDesc")& "/" &rsReport.Fields("comCode")& "/" &rsReport.Fields("MPN")& "/" &rsReport.Fields("QMPN")& "/" &rsReport.Fields("AML")& "/" &rsReport.Fields("SupplierName")&"/" &rsReport.Fields("LeadTime")& "'></td>")
End If
Response.write("</tr>")
End Function
%>
in my editor.. it din come out green color.. now all thecheckbox are disabled..!!!!! those with emai... also disabled
Hey lyealain,
HAHAHAHAHAAAA,
My code was perfect actually disabled=""\ + strCBstate + \"" is
not a correct practice...b'coz '\' is used to differentiate the nxt character from the actual string flow...
so it should be disabled=\"" + strCBstate + "\" then it won't change the text either to green & would treat it as a string argument while executing:)
& don't forget to set the 'strCBstate' string...u can even try with '&' inplace of '+'
That's it:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that
builds the sql string.
In the front end asp page, the checkbox code is written as follows:
<i><input...
|
by: Terence Parker |
last post by:
I'm not sure whether this question demands a JavaScript answer or a
simple HTML one - so apologies for the cross posting.
I am grabbing a bunch of data from MySQL using PHP and returning the...
|
by: Scott |
last post by:
Relative newbie here,
I'm looking to display the value of radio buttons and check boxes on the
page before submission. So far I can do most of it. When "Hat" is checked
there are to be no color...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: kiran |
last post by:
I cratee a form to meet the fallowing requirement.
1. If any node is selected the corresponding checkbox should be checked
2. If any checkbox is clicked the corresponding node should be selected
...
|
by: Jennyfer J Barco |
last post by:
Hello, I have a datagrid that brings some information from a query. I need
to have a checkbox in each row so the user can select the rows he wants to
reprint. Is it possible to have a checkbox...
|
by: Ceema M via DotNetMonster.com |
last post by:
Hello all,
I have a nested repeater, which displays categories(parent repeater) and
corresponding subcategories(child repeater). Both repeaters have checkboxes.
When I check category checkbox...
|
by: Jon Weston |
last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole
picture ctrl on a form that's source is the table that contains the pictures
and follow ALL the directions for embedding a...
|
by: remya1000 |
last post by:
I have a field called Departments in my database. and I have 3 monitors. So when Page_Load, I need to check number of departments I have in database. And depends upon that number of departments I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |