I found a way that works. I'm not sure if this is a good solution but it has held up under a few tests and it should be cross-browser compatible.
I found a few different sites that pointed me in the right direction and cobbled together an answer using what they said. Unfortunately I got them on my work computer so have no references to give here but I'll post them as an edit later.
Here is my new code:
<form method="link" action="/register">
<div class="tab">
<label for="preCompany">Company Name:</label>
<input type="text" size="20" id="preCompany" name="preCompany" onblur="var preCompany = document.getElementById('preCompany');"/>
<br/>
<label for="preEmail">Corporate Email:</label>
<input type="text" size="20" id="preEmail" name="preEmail" onblur="var preEmail = document.getElementById('preEmail');"/>
<br/>
<input type="submit" value="Continue..." onclick="TINY.box.show({url:'/register'}); return false;" />
</div>
</form>
Basically what I am doing here is setting a variable each time the user fills in one of the input boxes and then clicks away from that box. The tinybox script is called once the submit button is clicked. The two variables are global so can now be used by the Tinybox modal. The two variables can be empty.
Here is the code that is called in the modal window. It is also the regular registration page code so it seems that the variables do not need to be set at all and no error occurs.
<img src="/img/bg.gif" alt="" onload="document.getElementById('email').value = preEmail.value; document.getElementById('company').value = preCompany.value; this.parentNode.removeChild(this);" />
<?php echo form_open('register/register_form'); ?>
<table>
<tr>
<td><label for="email">Email:</label></td>
<td><input type="text" size="40" id="email" name="email"/></td>
</tr>
<tr>
<td><label for="company">Company Name:</label></td>
<td><input type="text" size="40" id="company" name="company"/></td>
</tr>
......
The sites that I referred to earlier explain this in a much better way but basically a modal window does not allow Javascript to be run so you have to force it. The recommended way was using something called eval()
but I ended up using this <img />
version which apparently works across browser and without any issues. All that happens is the img tag runs the Javascript which fills in the two inputs on the form with the contents of the variables that have just been set. A bit of JS then removes the img tag. IMPORTANT - The image referenced in the img tag needs to exist.
I'll post the sites where I find this info later which may help to explain what is happening here better than I can.
Thanks to itachi for the replies and help.
EDIT -
This page got me started on the path I went down - Tinybox does not run (eval) javascript code
This page helped some more - Running Javascript inside a simplemodal window
And this one gave me the answer for using an img tag to run the JS in the modal window - Can scripts be inserted with innerHTML?