Yes, I have been preoccupied!
Pass the form info. Well, it IS being passed, so I will assume you mean you want to prefill the form with data passed. Thats where PHP comes in. But you just opened a big canno-worms.
I am not sure that is a good idea, better to do the DHTML on one page and submit it, but.....
Text and hidden fields are easy.
Before:
Code:
<input name="title" type="text" id="title" tabindex="8" size="25" maxlength="25" onChange="document.getElementById('titleS').innerHTML=this.value;" />
After - (in the php code you submit the form to.)
Code:
<input name="title" type="text" id="title" tabindex="8" size="25" maxlength="25" value="<?php echo $_POST['title'];?>" onChange="document.getElementById('titleS').innerHTML=this.value;" />
Note we added a value attrib and used php to fill in the value.
Now, you have an additional problem. Your preview needs to display also, and so then you need to do this also if that is the case:
Code:
<script>document.getElementById('titleS').innerHTML=="<?php echo $_POST['title'];?>" </script>
Radio buttons - this is where things get ugly.
What you have
Code:
<input name="background" type="radio" id="background" style="cursor:pointer" onclick="document.getElementById('cardTemplate').style.backgroundImage='url(images/rgbblue.jpg)'" value="blue" />
<input name="background" type="radio" value="yellow" style="cursor:pointer" onclick="document.getElementById('cardTemplate').style.backgroundImage='url(images/yellow.jpg)'" />
What you need - the inellegant version. I won't be able to give you a lesson in arrays, which would streamline this tremedously.
First, to make things easier, we need to change the values to the actual image name. Then we use the CHECKED attrib to select the proper radio
Code:
<?php $chk=($_POST['background']=='rgbblue.jpg' ? 'CHECKED' : ''); ?>
<input name="background" type="radio" value="rgbblue.jpg" style="cursor:pointer" onclick="document.getElementById('cardTemplate').style.backgroundImage='url(images/rgbblue.jpg)'" <?php echo $chk; ?>/>
<?php $chk=($_POST['background']=='yellow.jpg' ? 'CHECKED' : ''); ?>
<input name="background" type="radio" value="yellow.jpg" style="cursor:pointer" onclick="document.getElementById('cardTemplate').style.backgroundImage='url(images/yellow.jpg)'" <?php echo $chk; ?>/>
.....
<script>document.getElementById('cardTemplate').style.backgroundImage='url(images/<?php echo $_POST['background'];?>)'" </script>
You may recall from a few pages back that this:
$chk=($_POST['background']=='rgbblue.jpg' ? 'CHECKED' : '');
is an if else loop and php supports this syntax also. Note that this one-line version is the same as the full syntax:
Code:
if ($_POST['background']=='rgbblue.jpg') {
$chk='rgbblue.jpg'
}
else {
$chk='';
}
And finally, the ugliness of a select box.
Before:
Code:
<select name="SIZEcompanyName" onchange="document.getElementById('companyName').style.fontSize=this.options[this.selectedIndex].value;">
<option value="8pt">8</option>
<option value="10pt">10</option>
<option value="12pt">12</option>
<option value="14pt">14</option>
<option value="18pt" selected="selected">18</option>
</select>
Code:
<select name="SIZEcompanyName" onchange="document.getElementById('companyName').style.fontSize=this.options[this.selectedIndex].value;">
<? $chk=($_POST['SIZEcompanyName']=='8pt' ? 'SELECTED' : ''); ?>
<option value="8pt" <?php echo $chk; ?>>8</option>
<? $chk=($_POST['SIZEcompanyName']=='10pt' ? 'SELECTED' : ''); ?>
<option value="10pt"<?php echo $chk; ?>>10</option>
<? $chk=($_POST['SIZEcompanyName']=='12pt' ? 'SELECTED' : ''); ?>
<option value="12pt"<?php echo $chk; ?>>12</option>
<? $chk=($_POST['SIZEcompanyName']=='14pt' ? 'SELECTED' : ''); ?>
<option value="14pt"<?php echo $chk; ?>>14</option>
<? $chk=($_POST['SIZEcompanyName']=='18pt' ? 'SELECTED' : ''); ?>
<option value="18pt" <?php echo $chk; ?>>18</option>
</select>
<script>document.getElementById('companyName').style.fontSize='<?php echo $_POST['SIZEcompanyName'];?>)'; </script>
Dose that help?