Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

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). Visit the ASP Development forum for help with ASP/VBScript and ASP/JScript applications.


Reply
 
LinkBack Thread Tools Display Modes
  #11  
Old June 19th, 2008, 02:48 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 19th, 2008, 03:02 PM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old June 19th, 2008, 03:04 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 19th, 2008, 03:08 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net 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
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.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
sbenj69 (June 19th, 2008)
  #15  
Old June 19th, 2008, 03:13 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 19th, 2008, 03:16 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 19th, 2008, 03:28 PM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old June 19th, 2008, 08:28 PM
dr_rock's Avatar
Drunk Barn Owl
 
Join Date: Jun 2008
Posts: 36
Thanks: 5
Thanked 3 Times in 1 Post
Rep Power: 1
dr_rock is on a distinguished road

Awards Showcase
Classic ASP 
Total Awards: 1

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  
Old June 19th, 2008, 08:35 PM
BLaaaaaaaaaarche's Avatar
Moderator
 
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

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


All times are GMT -4. The time now is 07:42 PM.



Content Relevant URLs by vBSEO 3.2.0