Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8387495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:13:37+00:00 2026-06-09T18:13:37+00:00

I need to insert multiple hidden fields(data) into the XML. Currently, I can only

  • 0

I need to insert multiple hidden fields(data) into the XML. Currently, I can only insert one data at one time. Let’s say that I have a few ’tiles'(which contains multiple coordinates) to insert into the XML. So, far, I can only insert one ’tile'(data) into the XML at one time.

<<==Javascript code==>>    

function moveIt(){ 

if (!moveEnabled||!MovableItem) return;

// display info during testing

X = MovableItem.offsetLeft;

Y = MovableItem.offsetTop;

W = MovableItem.offsetWidth;

H = MovableItem.offsetHeight;

document.getElementById('X').value = X;     
    document.getElementById('Y').value = Y;
    document.getElementById('W').value = W;
    document.getElementById('H').value = H;  

    document.form1.elements['X'].value;
    document.form1.elements['Y'].value;
    document.form1.elements['W'].value;
    document.form1.elements['H'].value;

    }

 <<==JSP codes==>>

 <form name='form1' action='UpdateXML.jsp' method='post'>

 <input type='hidden' name=source value="<%=src%>" />
 <input type='hidden' id="X" name="X" value="<%=X%>"/>
 <input type='hidden' id="Y" name="Y" value="<%=Y%>"/>
 <input type='hidden' id="W" name="W" value="<%=W%>"/>
 <input type='hidden' id="H" name="H" value="<%=H%>"/> 

 <button type="button" onclick="window.location.href='editcompany.jsp'">Back!</button>
 <button type="submit">Insert Into XML!</button>
 </form>

 <<==XML==>>

<%
try {

String X        = request.getParameter("X");
    String Y        = request.getParameter("Y");
    String W        = request.getParameter("W");
    String H        = request.getParameter("H");

    pw.println ( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"  );
    pw.println ( "<TemplateEditor>");
    pw.println ( "\t<Logo>");
    pw.print ( "\t\t<X_Coord>"); pw.print (X); pw.println ( "</X_Coord>");
    pw.print ( "\t\t<Y_Coord>"); pw.print (Y); pw.println ( "</Y_Coord>");
    pw.print ( "\t\t<Width>");   pw.print (W); pw.println ( "</Width>");
    pw.print ( "\t\t<Height>");  pw.print (H); pw.println ( "</Height>");
    pw.println ( "\t</Logo>");
    pw.println ( "</TemplateEditor>");

    pw.flush(); 
    pw.close();
    br.close();
    fw.close();
  } catch (Exception e) {}
%>

Hope there’s some kind soul out there who can help me out! I really really need help. Thanks a lot

Edit:

function $(v){return document.getElementById(v)}

function startMove(e){

if (!MovableItem){return;}

canvas=isIE ? "BODY" : "HTML";

    activeItem=isIE ? event.srcElement : e.target;  

    offsetx=isIE ? event.clientX : e.clientX;

    offsety=isIE ? event.clientY : e.clientY;

    lastX=parseInt(MovableItem.style.left);

    lastY=parseInt(MovableItem.style.top);

    lastW=parseInt(MovableItem.style.width);

    lastH=parseInt(MovableItem.style.height);

if (offsetx+scrollAmt[0]>=(MovableItem.parentNode.offsetLeft+parseInt(MovableItem.style.left)+(MovableItem.offsetWidth*.98))|| offsety+scrollAmt[1]>=(MovableItem.parentNode.offsetTop+parseInt(MovableItem.style.top)+(MovableItem.offsetHeight*.98)) ){edge=true; MovableItem.style.cursor="se-resize"} else{edge=false;MovableItem.style.cursor="move"}

moveEnabled=true;

document.onmousemove=moveIt;

}

Does this help? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:13:39+00:00Added an answer on June 9, 2026 at 6:13 pm

    Here are some hints and suggestions for handling N MovableItems (code is based on your current logic.

    NOTE: it doesn’t follow all JavaScript/JSP best practices (that I know of), it’s for demo purpose only.

    1.You can use just one hidden input field to save all MovableItems information (instead of creating 4xN hidden fields), because it’s easier to handle this way

    <input type='hidden' id="movableItems" name="movableItems" value="<%=value%>"/> 
    

    2.update moveIt() function to support N items.
    (Assume you have an array called MovableItems, which contains information of all items)

    function moveIt() {
        if (!moveEnabled || !MovableItems || MovableItems.length === 0) return;
        var value = '';
        for (var i = 0; i < MovableItems.length; i += 1) {
            if (i > 0) {
                value += '|';
            }
            value = [value, MovableItems[i].offsetLeft, ',',
                    MovableItems[i].offsetTop, ',',
                    MovableItems[i].offsetWidth, ',',
                    MovableItems[i].offsetHeight].join('');
        }
    
        //the hidden field's value would be something like 10,20,50,50|5,5,30,20|1,2,60,20
        document.getElementById('movableItems').value = value;
    }
    

    In UpdateXML.jsp

    try {
        pw.println ( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"  );
        pw.println ( "<TemplateEditor>");
    
        String value = request.getParameter("movableItems");
        String[] items = value.split("\\|");
        int size = items.length;
        for (int i=0; i<size; i++) {
            String[] coords = items[i].split(",");
            pw.println ( "\t<Logo>");
            pw.print ( "\t\t<X_Coord>"); pw.print(coords[0]); pw.println ( "</X_Coord>");
            pw.print ( "\t\t<Y_Coord>"); pw.print(coords[1]); pw.println ( "</Y_Coord>");
            pw.print ( "\t\t<Width>");   pw.print(coords[2]); pw.println ( "</Width>");
            pw.print ( "\t\t<Height>");  pw.print(coords[3]); pw.println ( "</Height>");
            pw.println ( "\t</Logo>");
        }
        ...
    } catch (Exception e) {}
    

    I’m sure there can be many other ways to do this. I hope this would give you some ideas.


    Edit:

    Here’s a possible way to create/update/delete MovableItems array:

    var MovableItems = []; //create an empty array
    

    A possible implementation for handling create/update/delete a MovableItem

    Note: it assume you assign each MovableItem a unique id when it’s generated in the UI

    function getItem(items, id) { //helper function for getting item from array by id
        for (var i = items.length; i >= 0; i -= 1) {
            if (items[i].id === id) {
                return i;
            }
        }
        return -1;
    }
    
    function updateMovable(MovableItem) {
        var index = getItem(MovableItems, MovableItem.id);
        if (item < 0) { //it's a new item
            MovableItems.push(MovableItem);
        } else { //it's an existing item
            MovableItems[index] = MovableItem;
        }
    }
    
    function deleteMovableItem(MovableItem) {
        var index = getItem(MovableItems, MovableItem.id);
        if (index) {
            MovableItems.splice(index, 1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert multiple rows into SQL Server database (100 at a time)
If I need to update or insert into multiple tables with one action, example
Need help with PHP Mysql code to insert multiple select data into database. With
I need some help to insert comma separates strings into multiple columns into db.
I need to split an amount into multiple part and insert into an table
I need to insert a huge amount of data into different tables within my
I need to insert multiple records into mysql database at once. What I am
I have a source piece of xml into which I want to insert multiple
Is there a quick way to insert multiple values into one column while the
I need to insert multiple records into a table. The number of records depend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.