...

View Full Version : Writing html using javascript then using cgi



Yoshi9143
02-16-2007, 09:20 PM
Hi!

A user on the interface I'm creating will enter a number. That will be the number of textfields that appear. I make the textfields appear by using javascript to write out html <input type="text" name="seg"> tags.

When the user presses submit, the server side cgi/perl script does not get the information. I am sending it via POST and I cannot figure out how to transmit the html input data that my javascript function writes.

If I cannot use javscript to do this is there any other method you may suggest?

Thanks for all the help,
Yosh

chump2877
02-16-2007, 09:53 PM
Can you post your HTML/Javascript code....that would help to see the problem...

I should also mention that you should not rely solely on JS to serve your HTML content, since JS can be disabled in a person's browser...If JS is disabled, then a user has no way to access or view your content...So, you can still use JS in this way, but you need to offer an alternative for non-JS users...

Which you might be doing (in which case you're off the hook ;)), so seeing your code would help in this case as well :)

Yoshi9143
02-16-2007, 10:19 PM
Here is the javascript:


function writit(text,id,step)
{
if(step=="one")
{
nums = text;
text = '<table cellspacing=0 cellpadding=0 border=0><tr><td>';
for(var i = 0; i < nums; i++)
{
tempi = i+1;
text = text + '<tr><td>'+tempi+'.</td><td> Starting SEGID: <input type="text" name="disustartsegid" size=4></td><td> Starting RESID:<input type="text" name="disustart'+i+'" size=4></td><td> Ending SEGID: <input type="text" name="disuendsegid'+i+'" size=4></td><td>Ending RESID:<input type="text" name="disuend'+i+'" size=4></td></tr>';
}
text= text + '</td></tr></table>';
printIt(text,id);
}
}
function printIt(text,id)
{
if (document.getElementById)
{
x = document.getElementById(id);
x.innerHTML = '';
x.innerHTML = text;
}
else if (document.all)
{
x = document.all[id];
x.innerHTML = text;
}
else if (document.layers)
{
x = document.layers[id];
text2 = '<P CLASS="testclass">' + text + '</P>;';
text2 = text2 + text;
x.document.open();
x.document.write(text2);
}
}


HTML:


<FORM name="solvmin" ACTION="/cgi-bin/master.cgi" METHOD="post">
<input type="text" name="numoffiles" id="numoffiles" value="0" size="4"n>

<input type="button" value="Enter number" class="smallbtn" onClick="doIt('numoffiles','makedisu','one'); return false">
<div id="makedisu">
</div>

<input type="submit" value="Enter" class="btn">



Thanks,
Yosh

chump2877
02-16-2007, 10:43 PM
I don;t see any declaration for the function "doIt()" (invoked in your onclick event)....did you forget to include that code?

Can you please also enclose your code in [CODE][./CODE] tags (minus the period inside the brackets)? It makes the code easier to read...

Yoshi9143
02-18-2007, 04:08 AM
I called doIt() here:


<input type="button" value="Enter number" class="smallbtn" onClick="doIt('numoffiles','makedisu','one'); return false">
<div id="makedisu">
</div>


Sorry about the code tags.

chump2877
02-18-2007, 04:21 AM
you need to include the javascript function code for doIt()...it should be in the following code somewhere, but it isn;t:


function writit(text,id,step)
{
if(step=="one")
{
nums = text;
text = '<table cellspacing=0 cellpadding=0 border=0><tr><td>';
for(var i = 0; i < nums; i++)
{
tempi = i+1;
text = text + '<tr><td>'+tempi+'.</td><td> Starting SEGID: <input type="text" name="disustartsegid" size=4></td><td> Starting RESID:<input type="text" name="disustart'+i+'" size=4></td><td> Ending SEGID: <input type="text" name="disuendsegid'+i+'" size=4></td><td>Ending RESID:<input type="text" name="disuend'+i+'" size=4></td></tr>';
}
text= text + '</td></tr></table>';
printIt(text,id);
}
}
function printIt(text,id)
{
if (document.getElementById)
{
x = document.getElementById(id);
x.innerHTML = '';
x.innerHTML = text;
}
else if (document.all)
{
x = document.all[id];
x.innerHTML = text;
}
else if (document.layers)
{
x = document.layers[id];
text2 = '<P CLASS="testclass">' + text + '</P>;';
text2 = text2 + text;
x.document.open();
x.document.write(text2);
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum