Welcome Guest, Not a member yet? Register   Sign In
question on how can I disable form_input area?
#1

[eluser]Nano HE[/eluser]
Hello.

How can I do this?
I want only disable one input area in my form.
And show some alert contents in the disabled form instead.

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
            );

    echo form_input($data);

and the webpage viwed like this,
Like this: [Disabled Search for Traffic Limitation]


#2

[eluser]CroNiX[/eluser]
Did you try adding
'disabled' => TRUE?
#3

[eluser]TWP Marketing[/eluser]
[quote author="Nano HE" date="1347580582"]Hello.

How can I do this?
I want only disable one input area in my form.
And show some alert contents in the disabled form instead.

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
            );
if( ! $disable )
{
    echo form_input($data);
}else{
echo ' [Disabled Search for Traffic Limitation]';
}

and the webpage viwed like this,
Like this: [Disabled Search for Traffic Limitation]
[/quote]
You will need to pass the flag: $disable from your controller as a boolean true/false
#4

[eluser]PhilTem[/eluser]
As CroNiX said you need to set the disabled attribute, however not in the way he said sine this is considered not RFC compliant, so use

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'disabled'    => 'disabled'
              'size'        => '25',
              //'style'       => 'width:20%',
            );

echo form_input($data);

which will create a form input that can not be edited though (and by the way won't be submitted when the form is submitted Wink )
#5

[eluser]CroNiX[/eluser]
@philTem, did you look at the html that using 'disabled' => TRUE produces? It's the same.
Code:
<input type="text" size="25" disabled="disabled" maxlength="100" id="searchform" value="" name="keyword">
#6

[eluser]PhilTem[/eluser]
Oh really, it does produce disabled="disabled"? I didn't know that. But I guess that's the point of forums: You never stop learning new stuff Wink Thanks, @CroNiX
#7

[eluser]Nano HE[/eluser]
Code:
echo form_open($formSearchOpenUrl, $attributes);
    $data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
     // 'disabled' => TRUE, // Worked!
     'disabled' => 'disabled',   // Also worked!

     'value'   => 'Disabled for Traffic Limitation'
            );

    echo form_input($data);

    echo form_submit('mysearchsubmit', 'Search', 'disabled');



Via URL: http://www.w3schools.com/tags/tag_input.asp
I found the default recommand attribute value for
Code:
'disable'
is
Code:
'disabled'
:-)

Thank you so much. My problem solved with your help. I posted my code here.




Theme © iAndrew 2016 - Forum software by © MyBB