views:

43

answers:

2

Iam using auto Complete method and spilliting the label and value

    $("#txt1").autocomplete({
    minLength: 1,
    source:  "/abc/ajax.php?param1=''&param2="+$("#txt1").attr("value"),
    select: function(event, ui) 
    {
                var label= ui.item.label;
        var value= ui.item.value;
        var Arr = label.split('-');                     
        $('#txt2').val( Arr[1].replace('$$$','') );

      }
    });

In the above code iam getting the name and value from server side script (PHP).Here i have Three thing to do

1)How do I replace the "$$$" in the label with a " " ( Suppose say i may have "($$)" and some time i may have "($)" how do i find the "$" constant in the label and replace with a " "(space)

2)How do i decrease the Font Size of the list of autocomplete Values that are displayed.

3) How do i apply color to the auto complete field .Iam dispalying the autocomplete in such way "NAME-Value". I want to apply different color for name and value

+1  A: 

How to replace the "$$$":

var str = "whatever $$$ text";
str = str.replace(/\$\$\$/g, "");
alert(str);

I haven't used JQuery's autocomplete plugin, but CSS is probably the way to go. Use a tool that lets you inspect the HTML from in the browers, to discover what CSS selctors to use.

element.class { font-size: 10pt; }

Color would be similar:

element.class { background-color: white; color: blue; }
John Fisher
Iam Not able to replace if i have the "$$"(only two dollar symbols).Iam able to replace the ThreeDollar($$$) symbol with the above code
Someone
This is just a regular expression issue. You should do a search to see how to write regular expressions. This one would be */\$+/g* in order to handle any number of dollar signs next to each other. Or, you could use */\$\$+/g* to handle 2 or more dollar signs next to each other.
John Fisher
replace(/\$/g, "")) ---I got it -- Thanks
Someone
How do I add the CSS Do we need add it in the CSS file
Someone
@Someone: You should look up tutorials on CSS. There are plenty of places to learn how it works. To answer your question, a CSS file or a <style></style> tag will work.
John Fisher
A: 

Your replace statement should be a regex string. $ indicates the end of a line in regex, to find a dollar sign you need to escape each one with a \ so your regex should be \$ for each one you want to match.

for the rest, just use CSS

JKirchartz