javascript - div disappears when page refreshed -


can't figure out why below piece of code makes textfield disappear upon page refresh (when 'no' radio button selected). also, after page refreshed default radio button doesn't selected.

forcing refresh, fixes problem, though.

any ideas?

<html> <body> <div class="editfield">         <div id="field_1">             <label>                 <input type="radio" checked="checked" name="radio-1" id="radio-1_id" value="yes" onclick="document.getelementbyid('divurl').style.display='none'">yes         </label>             <label>                 <input type="radio" name="radio-1" id="radio-2_id" value="no" onclick="document.getelementbyid('divurl').style.display='block'">no         </label>     </div> </div> <div class="editfield" id="divurl" style="display:none">     <label>website url</label>     <input type="text" name="x" id="x_id" value="" /> </div> </body> </html> 

<!doctype html> <html lang="en-us"> <body onload="document.getelementbyid('radio-2_id').checked=false; document.getelementbyid('radio-1_id').checked=true;"> <div class="editfield">         <div id="field_1">             <input type="radio" checked="checked" name="radio-1" id="radio-1_id" value="yes" onclick="document.getelementbyid('divurl').style.display='none'">             <label for='radio-1_id'>                 yes         </label>             <input type="radio" name="radio-1" id="radio-2_id" value="no" onclick="document.getelementbyid('divurl').style.display='block'">             <label for='radio-2_id'>                 no         </label>         </div> </div> <div class="editfield" id="divurl" style="display:none">     <label>website url</label>     <input type="text" name="x" id="x_id" value="" /> </div> </body> </html> 

just short recap:
1. on page refresh div should disappear (all css , js , html dynamically set / added removed) , selected radio button should first (yes)
2. tested on major browser , works
3. still can't figure out why wasn't working on mozilla , ie without js refresh



i moved radio buttons out of labels see if impacted refresh in way , didn't. also, removed </div> in original code.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -