Welcome Guest, Not a member yet? Register   Sign In
jquery 1.6 code into a form_input() ?
#1

[eluser]brucebat[/eluser]
Hi all,

I have been experimenting with this piece of javascript using jquery 1.6.2

http://jsfiddle.net/nNpjm/

Now I want to include it in the form_input() field by passing it as a variable with javascript inside?

However it does not seem to work using this:

Code:
$script = "input.click(function()
            {

            $(this).prop({selectionStart: 0, selectionEnd: 0});

            })
            
            .keydown(function()
            {

                var sel = $(this).prop('selectionStart'),
                val = $(this).val(),
                newsel = sel === 2 ? 3: sel;
                newsel = sel === 5 ? 6: newsel;

                $(this).val(val.substring(0, newsel) + val.substring(newsel + 1))

            .prop({
                selectionStart: newsel,
                selectionEnd: newsel
            });
            });";
            




echo form_input ($timeparam, set_value ('time'.$i), $script);


This is the html source is all messed up

Code:
<input type="text" name="time1" value="00:00:00" id="time1" maxlength="8" input.click(function()
            {

            $(this).prop({selectionStart: 0, selectionEnd: 0});

            })
            
            .keydown(function()
            {

                var sel = $(this).prop('selectionStart'),
                val = $(this).val(),
                newsel = sel === 2 ? 3: sel;
                newsel = sel === 5 ? 6: newsel;

                $(this).val(val.substring(0, newsel) + val.substring(newsel + 1))

            .prop({
                selectionStart: newsel,
                selectionEnd: newsel
            });
            }); />

Do I need to do it another way for this to work?

It uses onclick and keypush
#2

[eluser]toopay[/eluser]
Why not putting just an id attribute at input, then assign an inline script to handle that?




Theme © iAndrew 2016 - Forum software by © MyBB