Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Help with if statment code
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Classicmotorcycling
Development Team Leader

Australia
2085 Posts

Posted - 10 March 2005 :  05:13:21  Show Profile
Hello,

I am trying to get something like the following working:

I have a string from the database come out like so:

classic, motor, cycle, fred, Australia

I am trying to get if my if statment see's the string (for example) cycle to write "checked"

But on another search it is looking for the string David it says ""

It seems simple, but I for the life of me can not get it to happen. Is there anyone here that knows how to grab that string from an if statement?

What I have tried is this:

Response.Write "<input type="checkbox" name="Vechicle"" & vbNewLine
if Vechicle = "cycle" then
Response.Write "check" & vbNewLine
end if
Response.Write " value="cycle">  Cycle<br>" & vbNewLine

I am trying to have the check boxed checked if it was in the string, but if it is not in the string, then I do not want it checked. I am really stumped with this and know there are quite a few brainy people about that can help. Any help would be great.

Cheers,

David Greening

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 10 March 2005 :  05:29:12  Show Profile  Visit Gremlin's Homepage
The correct operand to mark the checkbox is "checked" not "check" You probably don't want the & vbNewLine in their either as that will split the HTML up and make the source harder to read.

Response.Write "<input type=""checkbox"" name=""Vechicle"" value=""cycle"""
if Vechicle = "cycle" then Response.Write " checked"
Response.Write "> Cycle<br>" & vbNewLine

Kiwihosting.Net - The Forum Hosting Specialists

Edited by - Gremlin on 10 March 2005 05:33:41
Go to Top of Page

Classicmotorcycling
Development Team Leader

Australia
2085 Posts

Posted - 10 March 2005 :  07:09:24  Show Profile
Thanks Gremlin,

Gave it a try and it did not work. I would like it to check if a word or string is in the string of words that may come out of the database and if there is a match, then it checks the box to say so.

I left the 'ed' of the code I typed in sorry about that..

Anymore help would be great..

Cheers,

David Greening
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 10 March 2005 :  07:16:53  Show Profile
Would instr not work?

if instr(","&StringFromDatabase&",",","&WordToCheck&",") then response.write "whatever you want"

Note: Wrapped everything in commas so a search for cycle wouldn't match something like unicycle.

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Classicmotorcycling
Development Team Leader

Australia
2085 Posts

Posted - 10 March 2005 :  09:38:55  Show Profile
That is why I like this site so much, cause I have been steered in the right direction again.. Got it working, thank you Shaggy and Gremlin.

Cheers,

David Greening
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 10 March 2005 :  09:43:46  Show Profile
You're welcome, Dave


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.41 seconds. Powered By: Snitz Forums 2000 Version 3.4.07