Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Writing html using javascript then using cgi

    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

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the javascript:
    Code:
    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:
    Code:
    <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
    Last edited by Yoshi9143; 02-18-2007 at 04:09 AM.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I called doIt() here:
    Code:
    <input type="button" value="Enter number" class="smallbtn" onClick="doIt('numoffiles','makedisu','one'); return false">
    <div id="makedisu">
    </div>
    Sorry about the code tags.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts
    you need to include the javascript function code for doIt()...it should be in the following code somewhere, but it isn;t:

    Code:
    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);
     }
    }
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •