kitty10
(Martde)
April 22, 2010, 11:02am
1
How do I hide/activate a button on a form?
<div id="clickme1" class="row buttons" >
<?php echo CHtml::submitButton('Save',array('submit' => '/tirociniStage/index.php?r=docente/create'),array("id"=>"studente")); ?>
</div>
I try with this,but don’t work
<script>
$().ready(function(){
$('studente').click(function(){
$('clickme1').toggleClass('hidden');
});
});
</script>
Can you help me?
mdomba
(Maurizio Domba Cerin)
April 22, 2010, 11:06am
2
$(‘clickme1’) should be $(’#clickme1 ’)
$(‘studente’) should be $(’#studente ’)
kitty10
(Martde)
April 22, 2010, 11:24am
3
Don’t work same…:-(((
Can you help me???
Should I remove the <script>
mdomba
(Maurizio Domba Cerin)
April 22, 2010, 11:40am
4
Try this code:
<?php
Yii::app()->getClientScript()->registerScript("myinit1","
$('#studente').click(function(){
$('#clickme1').toggleClass('hidden');
});
");
?>
Edit
<?php echo CHtml::submitButton(‘Save’,array(‘submit’ => ‘/tirociniStage/index.php?r=docente/create’),array(“id”=>“studente”)); ?>
should be
<?php echo CHtml::submitButton('Save',array(
'submit' => '/tirociniStage/index.php?r=docente/create',
"id"=>"studente"
)); ?>
mdomba
(Maurizio Domba Cerin)
April 22, 2010, 1:36pm
6
The code is working, but I think the problem is in the logic…
First… do you have in your CSS the class hidden?
.hidden {display:none;}
Second… the submit button when clicked will open a new page so what happens is that you click the button, the button is hidden but then the ‘/tirociniStage/index.php?r=docente/create’ is called and displayed as a new page, so you don’t see any more the page with the hidden button…
maybe to use ajaxSubmitButton ?
<div id="clickme1" class="row buttons" >
<?php echo CHtml::ajaxSubmitButton('Save','','',array(
"id"=>"studente"
)); ?>
</div>
but check the parameters… the second one is the URL you need, if it’s empty it means current page
This way when you click the button the button is hidden and the page remains with the hidden button
Hope it helps…
kitty10
(Martde)
April 22, 2010, 2:32pm
7
mdomba:
The code is working, but I think the problem is in the logic…
First… do you have in your CSS the class hidden?
.hidden {display:none;}
Second… the submit button when clicked will open a new page so what happens is that you click the button, the button is hidden but then the ‘/tirociniStage/index.php?r=docente/create’ is called and displayed as a new page, so you don’t see any more the page with the hidden button…
maybe to use ajaxSubmitButton ?
<div id="clickme1" class="row buttons" >
<?php echo CHtml::ajaxSubmitButton('Save','','',array(
"id"=>"studente"
)); ?>
</div>
but check the parameters… the second one is the URL you need, if it’s empty it means current page
This way when you click the button the button is hidden and the page remains with the hidden button
Hope it helps…
yes i have a class
.hide {display:none;} in my css
No, I need to make a 2 buttons one visible when I call a form and the other botton invisible when I call another form … as I do?
mdomba
(Maurizio Domba Cerin)
April 22, 2010, 8:08pm
8
If you have in the javascript code “toggleClass(‘hidden’)”, then the class should be .hidden not .hide