Hi all. I am working on a JS rollover maker. The first part of the code allows the user to enter the number of rollovers they need (up to 25) and displays the input fields in a form, like so:
code:
<script language="JavaScript">
<!-- Hide me
var myNumber = parseFloat(prompt("Enter a number between 1 and 25",""));
var loopCounter;
if (!(myNumber <= 25) && myNumber > 1)
{
while (!(myNumber <= 25))
{
myNumber = parseFloat(prompt("This is an invalid entry. Enter a number between 1 and 25",""));
}
}
// end hide -->
</script>
</head>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!-- Hide me
document.write('<form name="mouseOverForm" method="get">Image URL<P>');
for (loopCounter=0; loopCounter < myNumber; loopCounter++)
{
document.write('<input type="text" name="imgURL' + loopCounter + '" size="20"><P>');
}
document.write("</form>");
// Show me -->
</script>
The Second part of the code actually takes the information put in the input field and plugs it into a textarea, like so:
code:
<script language="JavaScript">
<!-- Hide me
function makeCode(form)
{
var imgURL = form.imgURL.value;
var headCode = "";
headCode += '<script language="Javascript">\r\n';
headCode += '<!-- hide me\r\n';
headCode += 'document.write("' + imgURL + '");\r\n';
headCode += '// show me -->\r\n';
headCode += '<' + '/script>';
form.theHead.value = headCode;
}
// end hide -->
</script>
</head>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!-- Hide me
document.write('<form name="mouseOverForm" method="get">Image URL<P>');
document.write('<input type="text" name="imgURL" size="20"><P>');
document.write('<input type="button" value="Create Code" onClick="makeCode(this.form);"><P>');
document.write('<textarea rows="4" cols="30" name="theHead" wrap="virtual"></textarea><P>');
document.write("</form>");
// Show me -->
</script>
The problem is, that I can't get the two codes to work together. How do I get the function to add the info for an unspecified number of HTML input fields? Thanks for the help.