Yii Framework Forum: submitButton - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

submitButton Rate Topic: -----

#1 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 22 April 2010 - 06:02 AM

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????
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,354
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 April 2010 - 06:06 AM

$('clickme1') should be $('#clickme1')

$('studente') should be $('#studente')
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 22 April 2010 - 06:24 AM

View Postmdomba, on 22 April 2010 - 06:06 AM, said:

$('clickme1') should be $('#clickme1')

$('studente') should be $('#studente')


Don't work same...:-(((
Can you help me???
Should I remove the <script>???
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,354
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 April 2010 - 06:40 AM

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"
)); ?>

Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 22 April 2010 - 08:17 AM

View Postmdomba, on 22 April 2010 - 06:40 AM, said:

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"
)); ?>


No don't work...:-(
0

#6 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,354
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 April 2010 - 08:36 AM

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...
Find more about me.... btw. Do you know your WAN IP?
0

#7 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 22 April 2010 - 09:32 AM

View Postmdomba, on 22 April 2010 - 08:36 AM, said:

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?
0

#8 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,354
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 April 2010 - 03:08 PM

If you have in the javascript code "toggleClass('hidden')", then the class should be .hidden not .hide
Find more about me.... btw. Do you know your WAN IP?
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users