javascript - Check if radio button value is, then echo some HTML -


i want check if value of select field value , if is, needs echo text.

i use code input box in form:

<li>     <div class="input-box">         <strong><?php echo $this->__('would recommend product friend?') ?></strong>         <?php foreach ( $this->getoptions() $option ): ?>             <label class="recommend">             <input type="radio" name="recommend" id="recommend_field                 <?php echo $option['value'] ?>" class="radio-gender" value="                 <?php echo $option['value'] ?>"                 <?php if ($option['value'] == $value)                      echo ' checked="checked"' ?> >                 <?php echo $this->__($option['label']) ?></input>         </label>         <?php endforeach ?>     </div> </li> 

and echo entire value of input box line:

<div id="reviewwriter">    <span class="recommendation">       <?php echo $this->getanswer() ?>    </span> </div> 

code loaded php:

public function confrecommenditemsarray() {     $resarray = array();     if (mage::getstoreconfig('advancedreviews/recommend_options/recommend_field1')) {         $resarray[] = array(             'value' => 1,             'label' => mage::getstoreconfig('advancedreviews/recommend_options/recommend_field1')         );     }     if (mage::getstoreconfig('advancedreviews/recommend_options/recommend_field2')) {         $resarray[] = array(             'value' => 2,             'label' => mage::getstoreconfig('advancedreviews/recommend_options/recommend_field2')         );     } 

and

class aw_advancedreviews_block_recommend_field extends mage_core_block_template {     public function canshow()     {         return (mage::helper('advancedreviews')->confshowrecommend()             && count(mage::helper('advancedreviews')->confrecommenditemsarray()));     }      public function getoptions()     {         return mage::helper('advancedreviews')->confrecommenditemsarray();     } } 

the values of select field
1. yes
2. no

i want check if value yes , if echo 'value yes'.
, if value no echo ''.

see jsfiddle: http://jsfiddle.net/wl3xu9d7/1/ not know why not working.

how can achieve that?

i hope solution want...

<li>     <div class="input-box">         <strong><?php echo $this->__('would recommend product friend?') ?></strong>         <?php foreach ( $this->getoptions() $option ): ?>         <label class="recommend">         <input type="radio" name="recommend" id="recommend_field<?php echo $option['value'] ?>" class="radio-gender" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' checked="checked"' ?>><?php echo $this->__($option['label']) ?></input>         </label>         <?php endforeach ?>     </div>  </li> 

add hidden field on answer

<div id="reviewwriter">    <span class="recommendation" id="reviewwriteranswer">       <?php echo $this->getanswer() ?>    </span>  </div>      <script> $$(".radio-gender").each(function(el) {             el.observe("click", function(event) {                  if(el.checked)                 {                    sub = $('reviewwriteranswer').value;               sub ==sub =.trim();                     if(el.value==sub)                     {                         $('reviewwriteranswer').update('value yes');                     }else {                         $('reviewwriteranswer').update('value no');                     }                 }             });         });  </script> <scrip> var allelements = document.body.getelementsbytagname("*"); for(var = 0; < allelements.length; i++) {     var text = allelements[i].innerhtml;     text=text.trim();      if (text == 'yes') {         allelements[i].innerhtml = "value yes";     }     if (text == 'no') {         allelements[i].innerhtml = "value no";     } } </scrip> 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -