I am wanting to build a table ag that allow the entry of 5 attributes namely a border value a bordercolor a bgcolor (background color) a cellpadding value and a cellspacing value.
The BB Code to be parsed would be bd , bdc, bgc, cp and cs as short hand.
I have managed to make the following work satisfactorily:
$txt = preg_replace( "#\[table bd=(\S+?)\s*\](.+?)\[/table\]#is", "<table border=\"\\1\">\\2</table>", $txt );$txt = preg_replace( "#(<table border=\"(.+?)\">)(.+?)(</table>)#is","[table bd=\\2\]\\3\[/table\]", $txt );
the first line converts [TABLE BD= **] into <table border= **> and works fine, but what I can't seem to get is how to convert the following into html properly the function produces the above tags but since they arent parsed properly the code does not work and here is that function:
function tag_table_bd()
{
var FoundErrors = '';
var tablebd = prompt("Enter the border value in numerals!","");
var tablebgcol = prompt("Enter the table background color name or HEX number!","");
var tablebdcol = prompt("Enter the table border color name or HEX number!","");
var tablepad = prompt("Enter the table cell padding value!","");
var tablecell = prompt("Enter the table cell spacing value!","");
doInsert( "[TABLE bd= "+tablebd+" bgc= "+tablebgcol+" bdc= "+tablebdcol+" cp= "+tablepad+" cs= "+tablecell+"]\n\n[/TABLE]\n", "", false);
}
Is there a way to make this parse all the attributes I have mentioned above by changing the existing code in the first example or should I try doing something different to achieve the objective? Then I can add som if statements after the parsing is correct to produce the table!