M.O.S. Studios Posted May 18, 2009 Share Posted May 18, 2009 hey guys, i tired to make a fucntions that copies info from two text box to make a unique short code. in this format: box 1: 12 box 2: 1 box 3 = EP12SE1 this is what i tired but with little luck funtion <script type="text/javascript"> function shortcode() { form1.shortcode.value = "EP" + form1.episode.value + "SE" + form1.season.value; } </script> html <form method='POST' action='account.php?actions=custmediaep' name="form1"> <table width='100%'> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSEASON; ?>: </td> <td 'width='60%'> <input type='text' name='season' id='season' value='<?php echo $season; ?>' size='2' maxlength='2'> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPEPISODE; ?>: </td> <td 'width='60%'> <input type='text' name='episode' id='episode' value='<?php echo $episode; ?>' size='3' maxlength='3' onchange="shortcode();"> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSHORTCODE; ?>: </td> <td 'width='60%'> <input type='text' id='shortcode' name='shortcode' value='<?php echo $shortcode; ?>' size='11' maxlength='11'> </td> </tr> </table> <input type='hidden' name='sent' value='1'> <center> <input type='submit' name='<?php echo ADD; ?>' value='<?php echo CUSTMEDIAEPBUTTADD; ?>'></center> </center> </form> any ideas?? thanks in advance Quote Link to comment Share on other sites More sharing options...
Adam Posted May 18, 2009 Share Posted May 18, 2009 Try: <script type="text/javascript"> function shortcode() { document.getElementById('shortcode').value = "EP" + document.getElementById('episode').value + "SE" + document.getElementById('season').value; } </script> Quote Link to comment Share on other sites More sharing options...
M.O.S. Studios Posted May 18, 2009 Author Share Posted May 18, 2009 keep getting this error from I.E. Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Mon, 18 May 2009 22:28:47 UTC Message: Object doesn't support this property or method Line: 350 Char: 1 Code: 0 URI: http://www.website.com that line number is this "<input type='text' name='episode' id='episode' value='<?php echo $episode; ?>' size='3' maxlength='3' onchange="shortcode();"> " Quote Link to comment Share on other sites More sharing options...
M.O.S. Studios Posted May 18, 2009 Author Share Posted May 18, 2009 ok I tried calling it with an onload and it works, however it dosn't seem to want to work with the onchange command this is the code i used to call it, <input type='text' name='episode' id='episode' value='' size='3' maxlength='3' onChange="shortcode();"> its driving me nuts, any ideas? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 Try this - <form method='POST' action='account.php?actions=custmediaep' name="form1"> <table width='100%'> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSEASON; ?>: </td> <td 'width='60%'> <input type='text' name='season' id='season' value='<?php echo $season; ?>' size='2' maxlength='2' onkeyup="shortcode();"> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPEPISODE; ?>: </td> <td 'width='60%'> <input type='text' name='episode' id='episode' value='<?php echo $episode; ?>' size='3' maxlength='3' onkeyup="shortcode();"> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSHORTCODE; ?>: </td> <td 'width='60%'> <input type='text' id='shortcode' name='shortcode' value='<?php echo $shortcode; ?>' size='11' maxlength='11' readonly="readonly"> </td> </tr> </table> <input type='hidden' name='sent' value='1'> <center> <input type='submit' name='<?php echo ADD; ?>' value='<?php echo CUSTMEDIAEPBUTTADD; ?>'></center> </center> </form> <script type="text/javascript"> function shortcode () { var ep = document.getElementById("episode").value; ep = /^\d+$/.test(ep)? "EP" + ep : ""; var sn = document.getElementById("season").value; sn = /^\d+$/.test(sn)? "SE" + sn : ""; document.getElementBy("shortcode").value = ep + sn; } </script> Quote Link to comment Share on other sites More sharing options...
M.O.S. Studios Posted May 19, 2009 Author Share Posted May 19, 2009 AUHG!! i thought forsure that was going to work, i don't know why but it keeps giving me that error when i try to call the function... any aother ideas? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 Oops.. <form method='POST' action='account.php?actions=custmediaep' name="form1"> <table width='100%'> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSEASON; ?>: </td> <td 'width='60%'> <input type='text' name='season' id='season' value='<?php echo $season; ?>' size='2' maxlength='2' onkeyup="shortcode();"> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPEPISODE; ?>: </td> <td 'width='60%'> <input type='text' name='episode' id='episode' value='<?php echo $episode; ?>' size='3' maxlength='3' onkeyup="shortcode();"> </td> </tr> <tr width='100%'> <td 'width='40%' align='right'> <?php echo CUSTMEDIAEPSHORTCODE; ?>: </td> <td 'width='60%'> <input type='text' id='shortcode' name='shortcode' value='<?php echo $shortcode; ?>' size='11' maxlength='11' readonly="readonly"> </td> </tr> </table> <input type='hidden' name='sent' value='1'> <center> <input type='submit' name='<?php echo ADD; ?>' value='<?php echo CUSTMEDIAEPBUTTADD; ?>'></center> </center> </form> <script type="text/javascript"> function shortcode () { var ep = document.getElementById("episode").value; ep = /^\d+$/.test(ep)? "EP" + ep : ""; var sn = document.getElementById("season").value; sn = /^\d+$/.test(sn)? "SE" + sn : ""; document.getElementById("shortcode").value = ep + sn; } </script> Quote Link to comment Share on other sites More sharing options...
Adam Posted May 19, 2009 Share Posted May 19, 2009 Try using it in Firefox and checking the error console there, you'll get a much more helpful error message! Quote Link to comment Share on other sites More sharing options...
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.