A man who tried to sell cocaine to an undercover Janesville police officer pretending to want to hire a prostitute will go to drug court with the opportunity to avoid a prison sentence.

Daniel S. Severson, 28, of 6269 W. Grand Videre Drive, Janesville, pleaded guilty Wednesday in Rock County Court to possession with intent to deliver cocaine.

Judge John Wood followed a plea agreement, withholding sentence until Severson completes or fails to complete the court-based rehabilitation program.

If Severson succeeds, the case will return to Wood’s court, where attorneys are recommending two years of probation and dismissal of a second charge, possession with intent to deliver designer drugs.

Drug court aims to set drug users on a path to longterm sobriety with therapy, regular drug testing and periodic appearances before a judge for progress updates.

Nearly a year ago, a Janesville police investigator searching local sex advertising sent a text message to a phone number listed in an online posting that advertised sex acts, according to the criminal complaint.

The undercover officer said he was looking for someone to perform sexual acts for a bachelor party, and the person responding agreed to meet him in the parking lot of an east-side apartment complex, according to the complaint.

The officer also asked about “other things” to bring to the party, and the person responding offered to find “fire coke,” according to the complaint.

The officer asked for “a ball,” street term for about one-eighth of an ounce of cocaine.

Severson arrived at the parking lot, as did another vehicle driven by Taylar M. Johnson, 20, of Janesville. Officers arrested them and found Severson in possession of more than one-half ounce of cocaine, according to the complaint.

Severson told police Johnson had contacted him about selling cocaine, so he met her there, according to the complaint.

Also found in Severson’s car was a scales with white powder residue, a box of Suboxone and five MDMA pills, according to the complaint.

Johnson told officers she had money troubles and thought that prostitution was her only employment option, so she had posted several ads in the previous few weeks, according to the complaint.

Johnson in April stood mute to charges of party to possession of cocaine with intent to deliver, possession of marijuana and drug paraphernalia and bail jumping. She failed to show up for court hearings in July, and a bench warrant was issued for her arrest.