DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Discuss "checkbox" 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
  #11 (permalink)  
Old June 19th, 2008, 02:48 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

Code:
<input type="checkbox" name="question1" id="question1" value"1">1
<input type="checkbox" name="question2" id="question2" value"2">2
<input type="checkbox" name="question3" id="question3" value"3">3
<input type="checkbox" name="question4" id="question4" value"4">4
<input type="checkbox" name="question5" id="question5" value"5">5
<input type="checkbox" name="question6" id="question6" value"6">6
<input type="checkbox" name="Other" id="Other" value"Other">Other

<input type="text" name="othertxt" id="othertxt" value="">

getquestion1=trim(Request.form("question1"))
getquestion2=trim(Request.form("question2"))
getquestion3=trim(Request.form("question3"))
getquestion4=trim(Request.form("question4"))
getquestion5=trim(Request.form("question5"))
getquestion6=trim(Request.form("question6"))

getOther=trim(Request.form("Other"))
getothertxt=trim(Request.form("othertxt"))


If getquestion1 <> "" Then
	getquestion1=getquestion1 & ", " 
End If

If getquestion2 <> "" Then
	getquestion2=getquestion2 & ", " 
End If


If getquestion3 <> "" Then
	getquestion3=getquestion3 & ", " 
End If

If getquestion4 <> "" Then
	getquestion4=getquestion4 & ", " 
End If

If getquestion5 <> "" Then
	getquestion5=getquestion5 & ", " 
End If

If getquestion6 <> "" Then
	getquestion6=getquestion6 & ", " 
End If

If getOther <> "" Then

	If getothertxt <> "" Then
	
		getOther=getOther & " - " &  getothertxt
	Else
		
		getOther=getOther & ", " 
	End If

End If

finalanswer=getquestion1 & getquestion2 & getquestion3 & getquestion4 & getquestion5 & getquestion6 & getOther
sometimes when i dont select other i have the comma at end and i need to delete it

can you guys tell me how to find out if there is comma at the end of string and if so then delete it

todd
Reply With Quote
Sponsored Links
  #12 (permalink)  
Old June 19th, 2008, 03:02 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 149
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Against my better judgment but...
If you ALWAYS have a comma at the end (i.e. append a comma after getothertxt), then you know you will need to delete the last character of the string EVERY TIME.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
  #13 (permalink)  
Old June 19th, 2008, 03:04 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

see if the user selects other then i dont have to worry

but if the user doesnt select other then i have the problem thats where i need to delete the comma
Reply With Quote
  #14 (permalink)  
Old June 19th, 2008, 03:08 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 537
Thanks: 14
Thanked 40 Times in 39 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

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

Default

Append the comma if the user selects "Other" anyway. Then you will always have to remove the last character. This is what I suggested a few posts up.
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
sbenj69 (June 19th, 2008)
  #15 (permalink)  
Old June 19th, 2008, 03:13 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

here is the code

Code:
<input type="checkbox" name="question1" id="question1" value"1">1
<input type="checkbox" name="question2" id="question2" value"2">2
<input type="checkbox" name="question3" id="question3" value"3">3
<input type="checkbox" name="question4" id="question4" value"4">4
<input type="checkbox" name="question5" id="question5" value"5">5
<input type="checkbox" name="question6" id="question6" value"6">6
<input type="checkbox" name="Other" id="Other" value"Other">Other

<input type="text" name="othertxt" id="othertxt" value="">

getquestion1=trim(Request.form("question1"))
getquestion2=trim(Request.form("question2"))
getquestion3=trim(Request.form("question3"))
getquestion4=trim(Request.form("question4"))
getquestion5=trim(Request.form("question5"))
getquestion6=trim(Request.form("question6"))

getOther=trim(Request.form("Other"))
getothertxt=trim(Request.form("othertxt"))


If getquestion1 <> "" Then
	getquestion1=getquestion1 & ", " 
End If

If getquestion2 <> "" Then
	getquestion2=getquestion2 & ", " 
End If


If getquestion3 <> "" Then
	getquestion3=getquestion3 & ", " 
End If

If getquestion4 <> "" Then
	getquestion4=getquestion4 & ", " 
End If

If getquestion5 <> "" Then
	getquestion5=getquestion5 & ", " 
End If

If getquestion6 <> "" Then
	getquestion6=getquestion6 & ", " 
End If

If getOther <> "" Then

	If getothertxt <> "" Then
	
		getOther=getOther & " - " &  getothertxt
	Else
		
		getOther=getOther & ", " 
	End If
else
	
	getOther=getOther & ", "
End If

finalanswer=getquestion1 & getquestion2 & getquestion3 & getquestion4 & getquestion5 & getquestion6 & getOther
I tried it like this


finalanswer = left(finalanswer, len(finalanswer)-1)

now it shows me 2 comma's at end of string


so i tried it like this

finalanswer = Trim(Left(finalanswer, Len(finalanswer) - 1))
Reply With Quote
  #16 (permalink)  
Old June 19th, 2008, 03:16 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

both methods dont work
Reply With Quote
  #17 (permalink)  
Old June 19th, 2008, 03:28 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 149
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Code:
If getOther <> "" Then

	If getothertxt <> "" Then
	
		getOther=getOther & " - " &  getothertxt & ", "
	Else
		
		getOther=getOther & ", " 
	End If
End If
and

Code:
finalanswer = Trim(finalanswer)
finalanswer = Left(finalanswer, Len(finalanswer)-1)

Comments on this post
sbenj69 agrees:
dr_rock agrees:
Reply With Quote
  #18 (permalink)  
Old June 19th, 2008, 08:28 PM
dr_rock's Avatar
Drunk Developer

 
Join Date: Jun 2008
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
Rep Power: 1
dr_rock is an unknown quantity at this point
Default

I have taken over a system that employs similar methods... ****s me to tears! Fortuantely they only store comma seperated integers, I would look at modifying the design if you can at all, and I would definately not recommend storing strings and integers jumbled up in the same list, but if you must then wollfys on the right track.

Last edited by dr_rock; June 19th, 2008 at 08:31 PM.
Reply With Quote
  #19 (permalink)  
Old June 19th, 2008, 08:35 PM
BLaaaaaaaaaarche's Avatar
Moderator

 
Join Date: Mar 2008
Posts: 43
Thanks: 10
Thanked 6 Times in 4 Posts
Rep Power: 1
BLaaaaaaaaaarche is on a distinguished road

Awards Showcase
Classic ASP 
Total Awards: 1

Default

Quote:
Originally Posted by Wolffy View Post
Ditto
Ditto x 2
__________________
"You'll never be as perfect as BLaaaaaaaaarche."
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
checkbox validation todd2006 JavaScript Programming 3 June 18th, 2008 07:22 PM
display problem checkbox todd2006 JavaScript Programming 4 May 30th, 2008 03:58 PM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 09:34 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46