SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DOM <select> IE problem

    Hi!
    I made select/option tags with DOM. It works nice in Mozilla but can't get it work in IE. Any ideas?

    Code:
    <html>
    <head>
    <script type='text/javascript'>
    function verify() {var p_d = document.opt_form.pull_d.selectedIndex; if(p_d == '0') {window.location.href = "script.php";}}
    </script>
    </head>
    <body>
    <script type='text/javascript'>
    
    var form_opt = document.createElement("form");
    var pd_opt = document.createElement("select");
    var opt_0 = document.createElement("option");
    var opt_t0 = document.createTextNode('1234');
    form_opt.name = 'opt_form';
    pd_opt.name = 'pull_d';
    form_opt.appendChild(pd_opt);
    pd_opt.appendChild(opt_0);
    opt_0.appendChild(opt_t0);
    pd_opt.onclick = function() {verify();};
    document.body.appendChild(form_opt);
    </script>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found it:

    Code:
    <html>
    <head>
    <script type='text/javascript'>
    function verify() {var no = document.getElementById("pull_d"); var p_d = no.options[no.selectedIndex].text; if(p_d == '1234') {window.location.href = "script.php";}}
    </script>
    </head>
    <body>
    <script type='text/javascript'>
    var form_opt = document.createElement("form");
    var pd_opt = document.createElement("select");
    var opt_0 = document.createElement("option");
    var opt_t0 = document.createTextNode('1234');
    form_opt.name = 'opt_form';
    pd_opt.id = 'pull_d';
    form_opt.appendChild(pd_opt);
    pd_opt.appendChild(opt_0);
    opt_0.appendChild(opt_t0);
    opt_0.value = '1234';
    pd_opt.onchange = function() {verify();};
    document.body.appendChild(form_opt);
    </script>
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •