Author |
Topic  |
|
Classicmotorcycling
Development Team Leader
    
Australia
2085 Posts |
Posted - 10 March 2005 : 05:13:21
|
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
|
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 |
 |
|
Classicmotorcycling
Development Team Leader
    
Australia
2085 Posts |
Posted - 10 March 2005 : 07:09:24
|
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 |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 10 March 2005 : 07:16:53
|
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.” |
 |
|
Classicmotorcycling
Development Team Leader
    
Australia
2085 Posts |
Posted - 10 March 2005 : 09:38:55
|
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 |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 10 March 2005 : 09:43:46
|
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.” |
 |
|
|
Topic  |
|