Jump to content

Easy comma-delimited list to dropdown box converter


Chad Seibert

Recommended Posts

Hello, Community

 

I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script.??? I had this to start with:

 

function ReplaceWithOption($stringtoreplace, $numtabs)
{
	//This creates a string that contains the number of tabs required to tab in and align the code
	for($x=0; $x < $numtabs; $x++)
		$tabs .= "\t";

	//Replaces all instances of ', ' with </option>\n<option> and aligns it
	$ret = preg_replace("/, /", "</option>\n".$tabs."<option>", $stringtoreplace);
	//This adds a blank option at the beginning and adds the starting and ending tags the above code
	//doesn't do
	$ret = "<option></option>\n".$tabs."<option>".$ret."</option>";

	return $ret;
}

 

But is there an easy way to get this to insert the id into it?

 

Thanks for any assistance :)

Chad Seibert

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.