23. oktober 2003 - 12:37
Der er
2 kommentarer og 1 løsning
preview av form
Vil gjerne av følgende kode skal skrive ut preview i bunnen av den eksisterende side i stedet for en helt ny side. <html> <head> <script language="JavaScript"> function preview(formelement) { document.write("<tr><td>Preview: "); document.write(formelement.value); document.write("</td></tr>"); } </script> </head> <body> <table width="100%" cellpadding="2" cellspacing="0"> <form method="get" action="index.php?op=2"> <tr> <td align="left">Device Name:</td> <td align="left" width="90%"><input type="text" name="name" size="50" maxlength="50" value="Device Name / Mask Id"></td> </tr> <tr> <td align="left" colspan="2"><input type="button" value="preview" onClick="preview(this.form.name);"> <input type="submit" name="submit" value="submit"></td> </tr> </form> </table> </body> </html>
Annonceindlæg fra GlobalConnect
23. oktober 2003 - 12:51
#1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>preview av form</title> <script language="JavaScript"> function preview(frm){ document.getElementById('view').innerHTML=frm.navn.value; document.getElementById('pre').style.display='block'; } </script> </head> <body> <table width="100%" cellpadding="2" cellspacing="0"> <form method="get" action="index.php?op=2"> <tr> <td align="left">Device Name:</td> <td align="left" width="90%"><input type="text" name="navn" size="50" maxlength="50" value="Device Name / Mask Id"></td> </tr> <tr> <td align="left" colspan="2"><input type="button" value="preview" onClick="preview(this.form);"> <input type="submit" name="submit" value="submit"></td> </tr> <tr id="pre" style="display: none;"> <td colspan="2"><div id="view"> </div></td> </tr> </form> </table> </body> </html>
23. oktober 2003 - 15:15
#2
mm12010, kanskje du lige kan se hvorfor dette ikke virker også da: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>preview av form</title> <script language="JavaScript"> function preview(frm){ document.getElementById('view').innerHTML=frm.navn.value; for(var i = 0; i < frm.revision.options.length; i++) if (frm.revision.options[i].selected) document.getElementById('revision').innerHTML=frm.revision.options[i].value; document.getElementById('pre').style.display='block'; } </script> </head> <body> <table width="100%" cellpadding="2" cellspacing="0"> <form method="get" action="index.php?op=2"> <tr> <td align="left">Device Name:</td> <td align="left" width="90%"><input type="text" name="navn" size="50" maxlength="50" value="Device Name / Mask Id"></td> </tr> <tr> <td align="left">Revision:</td> <td align="left"><select name='revision' class="textfield"><option>Rev-A</option><option>Rev-B</option><option>Rev-C</option><option>Rev-D</option><option>Rev-E</option> <option>Rev-F</option><option>Rev-G</option><option>Rev-H</option><option>Rev-I</option><option>Rev-J</option><option>Rev-K</option><option>Rev-L</option><option>Rev-M</option> <option>Rev-N</option><option>Rev-O</option><option>Rev-P</option><option>Rev-Q</option><option>Rev-R</option><option>Rev-S</option><option>Rev-T</option><option>Rev-U</option> <option>Rev-V</option><option>Rev-W</option><option>Rev-X</option><option>Rev-Y</option><option>Rev-Z</option></select></td> </tr> <tr> <td align="left" colspan="2"><input type="button" value="preview" onClick="preview(this.form);"> <input type="submit" name="submit" value="submit"></td> </tr> <tr id="pre" style="display: none;"> <td><div id="view"> </div></td><td><div id="revision"> </div></td> </tr> </form> </table> </body> </html>
24. oktober 2003 - 11:11
#3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>preview av form</title> <script language="JavaScript"> function preview(frm){ document.getElementById('view').innerHTML=frm.navn.value; alert(frm.revision.options.length); for(i=0;i<frm.revision.options.length;i++){ if(frm.revision.options[i].selected){ document.getElementById('rev_veiw').innerHTML=frm.revision.options[i].value; } } document.getElementById('pre').style.display='block'; } </script> </head> <body> <table width="100%" cellpadding="2" cellspacing="0"> <form method="get" action="index.php?op=2"> <tr> <td align="left">Device Name:</td> <td align="left" width="90%"><input type="text" name="navn" size="50" maxlength="50" value="Device Name / Mask Id"></td> </tr> <tr> <td align="left">Revision:</td> <td align="left"><select name='revision'><option value="Rev-A">Rev-A</option><option value="Rev-B">Rev-B</option><option value="Rev-C">Rev-C</option></select></td> </tr> <tr> <td align="left" colspan="2"><input type="button" value="preview" onClick="preview(this.form);"> <input type="submit" name="submit" value="submit"></td> </tr> <tr id="pre" style="display: none;"> <td colspan=2><div id="view"> </div> - <div id="rev_veiw"> </div></td> </tr> </form> </table> </body> </html>