Jump to content
  • 0

Скрыть див при активном радиоботтоне


sashka
 Share

Question

Здравствуйте

При активном радиоботтоне нужно скрыть див с содержимым, для этого используется JS:

<script type="text/javascript">var inp = document.getElementsByName('shipping_rate_id'); myadresLab = document.getElementById('vm_myadres_div'); myadresInp = document.getElementById('vm_myadres_input') pasportLab = document.getElementById('vm_pasport_div'); pasportInp = document.getElementById('vm_pasport_input');function func (elm) {	if (elm.id == "hashd5561dda4545a69195256a8ee62fcc91" && elm.checked){//Самовывоз radiobutton		myadresLab.style.display = "none";		myadresInp.style.display = "none";		pasportLab.style.display = "none";		pasportInp.style.display = "none";	}	else if (elm.id == "hasha917f3643fcc7141bc83f55fb83a6c62" && elm.checked){//Доставка по Москве radiobutton		myadresLab.style.display = "";		myadresInp.style.display = "";		pasportLab.style.display = "none";		pasportInp.style.display = "none";	}	else{		myadresLab.style.display = "";		myadresInp.style.display = "";		pasportLab.style.display = "";		pasportInp.style.display = "";	}}for (var i=0;i<inp.length;i++){   inp[i].onchange = function () {func(this)};}</script>

вот пример в работе: http://www.glassbus.ru/Untitled-14.html

 

Пожалуйста, помогите изменить код, чтобы в нем не было вызова функции (код будет размещен в функции другого JS).
(Без onclick или onchange в инпуте radio. Без jQuery)

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy