Jump to content

copying info from textbox 1 & 2 into box 3


M.O.S. Studios

Recommended Posts

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

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();">

"

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?

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>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.