[Javascript] Re:posting arrays

Bill Marriott bill.marriott at optusnet.com.au
Tue Oct 9 14:56:12 CDT 2001


Thanks for that Esther,

I think your code should work.
However I have decided not to use this approach now.
I think I'll end up with too much code on the page ( the page has 4 of these
tables that I need to cater for) and the display time will be too slow for
the remote users. But I'll store your idea for later.

Bill
----- Original Message -----
From: <Esther_Strom at hmco.com>
To: <javascript at LaTech.edu>
Sent: Tuesday, October 09, 2001 11:14 PM
Subject: Re: [Javascript] Re:posting arrays


>
> Don't know if this will work in actuality, but theoretically (ah, how
often
> we hear that!)...
>
> Why not create a semicolon (or tilde, or some other uncommon character) -
> delimited text string (link1~link2~link3). Set that as a hidden input and
> post to the next page. Then have a function on the next page split out the
> elements using split().
>
>
> var my_links = "link1~link2~link3~link4"; file://pass this as a hidden
element
>
> var link_array = my_links.split("~");
>
> for (loop=0; loop < link_array.length;
> loop++)
>
> {
>
>    document.writeln(link_array[loop] + " is a link to delete.<br>");
>
> }
>
> "This breaks the string my_links into an array of five elements. (Happily,
> JavaScript creates the array for you automatically, so you don't have to
> use new Array() to create it yourself). "
>
> (Above courtesy of Webmonkey...)
>
>
>
>
>                     "Bill Marriott"
>                     <bill.marriott at optusn        To:
<javascript at LaTech.edu>
>                     et.com.au>                   cc:
>                     Sent by:                     Subject:     [Javascript]
Re:posting arrays
>                     javascript-admin at LaTe
>                     ch.edu
>
>
>                     10/04/01 10:27 PM
>                     Please respond to
>                     javascript
>
>
>
>
>
>
> Hi Everyone,
>
> Thanks for your help in the past.
>
> I have a new problem with posting arrays.
>
> I want to use an array
>
> var linksToDelete = new Array();
>
> to store the ID's of records to delete from the database.
>
> I have got the javascript (see below) to add the elements to the array as
> the user deletes a record from the page.
>
> How can I post the array(with all the elements) to the next page in order
> to do the processing for the deletes. The <input hidden tag> dosen't want
> to post the array!
>
>
>
> <SCRIPT LANGUAGE=Javascript>
> var ns = (navigator.appName.indexOf('Netscape')>-1);
> var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1);
>
> var linkCount = <?MIVAR>$LINKCOUNT<?/MIVAR>;
> var linksToDelete = new Array();
> var deleteCount = 0;
>
> function removeRow(e)
> {
> if (confirm("Do you want to delete this row?"))
>    {
>  if (ns)
>  {
>   var srcElement = e.target;
>  }
>  else
>  {
>   var srcElement = event.srcElement;
>  }
>  if (srcElement.nodeType == 3)
>  {
>   srcElement = srcElement.parentNode;
>  }
>  var delRow = srcElement.parentNode.parentNode;
>  var tBodyObj = document.getElementById("linkTBody");
>         linksToDelete[deleteCount] = delRow.id;
>         alert(linksToDelete[deleteCount]);  ////this works here
>         document.editTable.LINKSTODELETE[deleteCount].value=delRow.id;
////
> THIS LINE IS NOT WORKING
>         deleteCount++;
>         tBodyObj.removeChild(delRow);
>         linkCount--;
>         document.editTable.LINKCOUNT.value=linkCount; ////single input
> hidden tag in the form
>         document.editTable.DELETELINKCOUNT.value=deleteCount; //// single
> input hidden tag in the form
>    }
> else
>    {
>     ////cancel;
>    }
> }
> </SCRIPT>
>
> <INPUT TYPE="hidden" name="LINKCOUNT" Value="<?MIVAR>$LINKCOUNT<?/MIVAR>">
> <INPUT TYPE="hidden" name="LINKSTODELETE[]" >
> <INPUT TYPE="hidden" name="DELETELINKCOUNT" Value="0">
>
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list