Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

Discuss "Field that is a link (rs) and/or text field question" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Reply « Previous Thread | Next Thread »
 
LinkBack Thread Tools Display Modes
  #1  
Old July 10th, 2008, 02:05 PM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default Field that is a link (rs) and/or text field question

Hi All,

Ok, I have the following field on my form because if the Item does not have a price (intItem is ItemCost) is not zero then I don't want to allow users to change/update the ItemDescription but it will also be a link to BOMMaster page....but if it is zero they can have a text field to input a ItemDescription, these will not have BOMMasters....

Code:
<TD align=right>
<%
If intItem <> 0 then
%>
<a href="//testserver/application/BOMMaster.asp?ItemID=<%=rs("ItemID")%>" target="_blank"><%=rs("ItemDesc")%></a> &nbsp;</TD>
<%
else
%>
<INPUT CLASS="clrBg" type="text" name="InputItemDesc" size="30" maxlength="4" value="<%=rs("ItemDesc")%>"</TD> <%
End If
%>
</TD>

Question: I added "InputDescription" field to my tblDetails, how can I update this field from the above code? since I dont have a (Name="InputItemDesc") on the ones that do have a itemcost? Right now "Desc" (rs) is being pulled from another table (tblItem) "ItemDescription".
Reply With Quote
Sponsored Links
  #2  
Old July 10th, 2008, 02:11 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

I guess I don't understand your question. To update the field in the database just submit the form using the ItemID to identify the record and then update the data.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old July 10th, 2008, 02:19 PM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Hiya JMH,

But my form has multiple items, example:
The underlined ones below are the ones with a itemcost > 0

Code:
Category1
-Group1
ItemDescription1-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
ItemDescription2-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
ItemDescription3-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
When I do my update, I will look at RegionID,DistrictID,ItemID.....will that still work like that?
Reply With Quote
  #4  
Old July 10th, 2008, 02:30 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

Each of those items should have an ID in the database. You will simply have to loop through them and run an update query using that ID to update the data.

Instead of InputItemDesc, call it InputItemDescXX, where XX is the ID. Then, when the form is submit, query the database for that group to pull all of those IDs and if InputItemDescXX = the recordID AND has a data inside, update the query.

For example:
Code:
'The form has been submit
sql = "SELECT itemID From ItemDesc WHERE groupID = " & Request.Form("groupID")
 
'Create recordset and execute the query here
...
 
'Loop through the query
Do While Not rs.BOF And Not rs.EOF
    If Len(Request.Form("InputDesc" & rs("itemID"))) > 0 Then
        sql = "UPDATE ItemDesc SET ItemDesc = '" & Request.Form("InputDesc" & rs("itemID")) & "' WHERE itemID = " @ rs("itemID")
        
        'Execute update statement
    End If
rs.MoveNext
Loop
Make sense?
Reply With Quote
  #5  
Old July 10th, 2008, 02:39 PM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Ok, kind of....I think I'm still a little confused by myself dealing with the ones they can change (desc/input cost)....let me give it a try and see how it comes out....Thanks JMH!!! Will keep ya posted on the progress.
Reply With Quote
  #6  
Old July 14th, 2008, 09:25 AM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Ok, I added something like this but just realized I have another issue....you first go in an if the intItem is 0 then you can enter a price but after I've entered a price what happens if I want to change it...it's no longer 0? Crud, have to rethink this again.

Code:
<TD align=right>
<%
If intItem <> 0 then
%>
<INPUT CLASS="clrBg" type="text" name="InputItemDesc<%response.write(i)%>" size="30" maxlength="4" readonly value='<%=rs("ItemDesc")%>'</TD>
<%
else
%>
<INPUT CLASS="clrBg" type="text" name="InputItemDesc<%response.write(i)%>" size="30" maxlength="4" value='<%=rs("ItemDesc")%>'</TD>
<%
End If
%>

Last edited by Rebelle; July 14th, 2008 at 09:48 AM. Reason: changed code above.
Reply With Quote
  #7  
Old July 14th, 2008, 10:10 AM
BLaaaaaaaaaarche's Avatar
Administrator


 
Join Date: Mar 2008
Posts: 55
Thanks: 10
Thanked 7 Times in 5 Posts
Rep Power: 1
BLaaaaaaaaaarche is on a distinguished road

Awards Showcase
HTML & CSS Classic ASP 
Total Awards: 2

Default

Why are you only allowing them to change the price if it is 0? What is the difference?
__________________
"You'll never be as perfect as BLaaaaaaaaarche."
Reply With Quote
  #8  
Old July 14th, 2008, 10:23 AM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

oops...just saw your reply...was in shoutbox.

i have an Item table where the item desc and cost is stored...some of those items are $0. Those are items that I need to allow to change the Item description and the cost (because desc is something like Misc.). All other items should not be changed.

so since each district will have its own results, i added a details table which will hold each districts details (items/cost/qtrs, etc.) but I went back and added a location cost field and district input desc field because i need to show any ones they can change the desc/cost as what they change it to.

but now since the asp code looks to see if the cost is $0....what happens if they have entered a price for a misc item and put $20, they will longer be able to change it.

should my view contain both the cost from items table and district cost from details table..? would this take care of the issue above?
Reply With Quote
  #9  
Old July 14th, 2008, 07:05 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

So why are you doing that check in the first place? If they need to be able to edit everything...allow them to. Your logic needs to be rethought. Why even store items in the database if it doesn't have a real value? I would have a table that stores possible items. Then use that and create a relationship with another table that actually stores the data for each district. If you could script a SQL Server database for us and populate it with some values, we could probably show you a better solution.
Reply With Quote
  #10  
Old July 15th, 2008, 10:51 AM
Rebelle's Avatar
V.I.P/Donor


 
Join Date: Mar 2008
Posts: 254
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Hopefully i did it right.... I've attached the sql tables that I'm using. I created a view but it's not in the attached file, should i script it too? I've got the asp page setup to show all categories, groups, items then it sums each category, then a grand total at the end. just need to work on flow/edit screen (only edit items that are Misc items with $0). All others should stay as assigned in the items table because I will need to somehow show a page with all Regions/Districts combined.

I'm thinking i'm going to plug in data into the details table for each districts with Null in the qtrs so they can have something to start with....then all they will be doing is editing those same records.
Attached Files
File Type: zip PlanTables.zip (675 Bytes, 1 views)
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel question Rebelle Microsoft Office 11 May 27th, 2008 07:22 PM
C# database question peebman2000 .Net Development 19 April 21st, 2008 03:23 PM
Using a field value in an IN(...) clause richyrich MySQL 5 April 13th, 2008 11:56 AM
Suggestions - ChangedOn field Rebelle ASP Development 7 April 8th, 2008 02:07 PM
Help with Updating field Rebelle Microsoft Access 5 April 1st, 2008 06:45 PM


All times are GMT -4. The time now is 06:29 PM.



Content Relevant URLs by vBSEO 3.2.0