在灯箱弹出窗口中使用javascript预览表单

时间:2012-09-08 14:16:09

标签: javascript forms popup lightbox preview

请在弹出窗口中预览表单时需要一些帮助。我有一个表格,非常大,所以我添加了预览选项以显示为弹出窗口。灯箱形式弹出窗口效果很好,但我现在遇到的问题是函数passform()将输入(textfield,select,checkbox,radio)传递到弹出页面以便在Click()上进行预览。 以下是我的javascript和html代码。我离开了CSS和一些html,因为我认为它们没有必要。我将感谢你的帮助。谢谢

Javascript

function gradient(id, level)
 {
var box = document.getElementById(id);
box.style.opacity = level;
box.style.MozOpacity = level;
box.style.KhtmlOpacity = level;
box.style.filter = "alpha(opacity=" + level * 100 + ")";
box.style.display="block";
return;
}


function fadein(id) 
 {
var level = 0;
while(level <= 1)
{
    setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
    level += 0.01;
}
   }


     // Open the lightbox


  function openbox(formtitle, fadin)
   {
    var box = document.getElementById('box'); 
    document.getElementById('shadowing').style.display='block';

    var btitle = document.getElementById('boxtitle');
    btitle.innerHTML = formtitle;

    if(fadin)
     {
 gradient("box", 0);
 fadein("box");
     }
    else
     {  
     box.style.display='block';
     }      
     }


      // Close the lightbox

     function closebox()
     {
      document.getElementById('box').style.display='none';
      document.getElementById('shadowing').style.display='none';
     }

     //pass form fields into variables
     var divexugsotherugsexams1 = document.getElementById('divexugsotherugsexams1');
     var exugsotherugsexams1 = document.form4.exugsotherugsexams1.value;

     function passform()
     {
      divexugsotherugsexams1.innerHTML = document.form4.exugsotherugsexams1.value;
     }

HTML(只有一个文本字段尝试):

      <p><input name="submit4" type="submit" class="button2" id="submit4" value="Preview Note" onClick="openbox('Preview Note', 1)"/>
  </p>
  <div id="shadowing"></div>

   <div id="box">
  <span id="boxtitle"></span>
  <div id="divexugsotherugsexams1"></div>

  <script>document.write('<PARAM name="SRC" VALUE="'+exugsotherugsexams1+'">')</script> 
      <a href="#" onClick="closebox()">Close</a>

   </div>

0 个答案:

没有答案