Forum Moderators: open

Message Too Old, No Replies

Call saved file

Pass form data

         

treeleaf20

7:13 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



Hello all,
I was wondering if you can pass data from a form that I created to a file that has <div> tags. I created a template and took out all the content that I would need changed. The form is what the user wants to have filled into the template. Is there anyway that I can put the data from the form into the <div> tags without having to actually take all the code and do getElementById and all of that good stuff. So basically when the form gets submitted it looks to see which template it should grab and it will fill in the <div> tags with the appropriate data. Here is the code minus some things for length to hopefully get a better understanding:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" type="text/css" href="http://www.cigna.com/includes/style.css">
<link id="style2" rel="STYLESHEET" type="text/css" href="http://www.cigna.com/general/includes/style_ge.css">

<script language="JavaScript" type="text/JavaScript">
function validate(){
var mycontact=-1;
for (d=0;d<template.choosetemplate.length;d++) {
if (template.choosetemplate[d].checked) {mycontact=d;}
}
if (mycontact==-1) {
alert ('Please select a template type.');
return false;
}

var mycontact=-1;
for (d=0;d<template.callout.length;d++) {
if (template.callout[d].checked) {mycontact=d;}
}
if (mycontact==-1) {
alert ('Please select if you want a callout.');
return false;
}

if (template.breadcrumb_label.value == ""){alert ('Please enter a breadcrumb label value'); return false;}
if (template.breadcrumb_link.value == ""){alert ('Please enter a breadcrumb link value'); return false;}
if (template.breadcrumb_pagename.value == ""){alert ('Please enter a breadcrumb current page value'); return false;}
if (template.center_content.value == ""){alert ('Please enter center content'); return false;}

return true;


}

function checkVal()
{
if(document.theForm.newCode.value=="")
{
alert('Please enter the content you\'d like displayed...');
document.theForm.newCode.focus();
return false;
}
return true;
}

</script>

</head>

<body>
<p class="cignatitle">The Ultimate Template Creator</p>
<form name="template">
<strong>Please choose a template</strong>:
<table width="200">
<tr>
<td><label>
<input type="radio" name="choosetemplate" value="hc">
Health Care</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="choosetemplate" value="gr">
Group</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="choosetemplate" value="re">
Retirement</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="choosetemplate" value="ge">
General</label></td>
</tr>
</table><br>
<strong>Would you like callouts:</strong><br>
<table width="200">
<tr>
<td><label>
<input type="radio" name="callout" value="yes">
Yes</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="callout" value="no">
No</label></td>
</tr>
</table>
<strong><br>
Please input breadcrumbs:</strong><br>
<table width="386" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="56">Label:</td>
<td width="330"><input name="breadcrumb_label" type="text" size="35"></td>
</tr>
<tr>
<td colspan="2"><img src="http://www.cigna.com/images/clear.gif" width="1" height="5"></td>
</tr>
<tr>
<td>Link</td>
<td><input name="breadcrumb_link" type="text" size="35"></td>
</tr>
</table><br>
<p><strong>Page Name (for last breadcrumb):</strong> <br>
<input name="breadcrumb_pagename" type="text" size="35">
</p>
<p><br>
<strong>Please enter the center content:</strong><br><a href="#" onClick="javascript:addHREF();">HREF LINK</a> ¦ <a href="#" onClick="javascript:addparagraph();">Paragraph</a> ¦ <a href="#" onClick="javascript:addparagraphclass();">Paragraph with a Class</a> ¦ <a href="#" onClick="javascript:addlinebreak();">Line Break</a> ¦ <a href="#" onClick="javascript:addimage();">Image</a><br>
<div id="centerbutton"></div>
<textarea name="center_content" cols="70" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Create Template" onClick="return validate();">
</p>
</form>
</body>
</html>

So it would fill in the center_content <div> tag with what is in the textarea named center_content and so forth. It would choose the template based on the radio buttons picked. Please help!

Rambo Tribble

2:23 am on Aug 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This really sounds like a job for a server-side script. Passing variables between pages on the client side is possible, but requires either window dependencies or cookies. And, think of document.getElementById() as your friend. To do what you ask quickly and directly, I think you'd need to use that method. The innerHTML property might be of use, as well.