473,811 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Concatenating dynamically created text box values

Chi
Hi There,

The following is a popup form that works exactly as I want but I now
need to get the values of each text box added when a user clicks the
'Add' button and pass the values back the opener form into a textarea.

Thanks in advance!

=============== =============== ==
CODE BELOW
=============== =============== ==

<html>
<head>
<script language="javas cript">
function AddURL()
{
var theTable = document.getEle mentById('tblUR L');
var URL = document.getEle mentById('URL') .value;

// create a new row object
var newRow = document.create Element("tr");

// create new cell objects
var urlTextCell = document.create Element("td");
var urlEditCell = document.create Element("td");
var previewButtonCe ll = document.create Element("td");
var deleteButtonCel l = document.create Element("td");

// create text field for urlEditCell
var newInput = document.create Element("INPUT" );
newInput.type= "text";
newInput.value = URL;
urlEditCell.app endChild(newInp ut);

// create a preview/test button and add to the previewButtonCe ll
var newInput = document.create Element("INPUT" );
newInput.type= "button";
newInput.value = "Test";
newInput.onclic k = new Function("previ ewURL('"+ URL + "')");
previewButtonCe ll.appendChild( newInput);

// create delete button and add to the deleteButtonCel l
var newInput = document.create Element("INPUT" );
newInput.type= "button";
newInput.value = "Delete";
newInput.onclic k = DeleteURL;
deleteButtonCel l.appendChild(n ewInput);

// set the text and buttons of each cell
newRow.appendCh ild(urlTextCell );
newRow.appendCh ild(urlEditCell );
newRow.appendCh ild(previewButt onCell);
newRow.appendCh ild(deleteButto nCell);

// create a new row and replace it with your created row
var tempRow = theTable.insert Row();
tempRow.replace Node(newRow);

// reset cell and set focus for next entry
document.frmURL .URL.focus();
document.frmURL .URL.value = '';
}

function DeleteURL()
{
// grab the containing row
var theRow = event.srcElemen t.parentElement .parentElement;
theRow.removeNo de(true);
}

function previewURL(theU RL)
{
window.showModa lDialog(theURL, "","dialogHeigh t: 500px; dialogWidth:
500px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help:
No; resizable: Yes; status: No;");
}

var validated = false;

function myValidate(mode )
{
if (!mode && !validated) return false;
if (mode)
{
validated=true; formReference.s ubmit();
}
return true;
}
</script>
</head>
<body onLoad="documen t.frmURL.reset( );"></body>
<form action="" name="frmURL" onSubmit="retur n myValidate(fals e)">
<fieldset style="padding: 5px; margin-bottom:3px;">
<legend>Alterna te Content URL(s)</legend>
<br>
<input id="URL" type="text" size="35"
value="http://www.cnn.com"><i nput type="button" value="Add"
onclick="AddURL ()"/>
<br>
<br>
<table border="0" cellspacing='3' id ="tblURL"></table>
</fieldset>
<div align="right">
<input type="button" value="Save" onClick="">
<input type="button" value="Cancel" onClick="">
</div>
</form>
</body>
</html>
Jul 20 '05 #1
1 11323
In article <25************ **************@ posting.google. com>,
we********@hotm ail.com enlightened us with...
Hi There,

The following is a popup form that works exactly as I want but I now
need to get the values of each text box added when a user clicks the
'Add' button and pass the values back the opener form into a textarea.

Thanks in advance!


Substitute your form names in the code. Assumes you want the values of
ALL text elements in the form.

var s="";
var l = document.formNa me.elements.len gth; //popup form name here
for (var i=0; i<l; i++)
{
e = document.formNa me.elements[i]; //popup form name here
if (e.type=="text" ) s+= e.value+" "; // space between values so
one can read them
}
opener.document .formName.eleme ntName.value = s; //opener form name and
the textarea name here

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4318
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
3
1967
by: Jen | last post by:
Hi I have created some controls (HtmlInputText, HtmlGenericControl, TextBox) dynamically. But I have problem getting the values from these controls to save them. Is there a way to do that? Regards and Many thanks Jen
2
2917
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
1
3417
by: Marcus | last post by:
I have a problem maybe one of you could help me with. I've created a data entry screen with lots of dynamically-created client-side controls. I create HTML texboxes client-side by assigning a value to the td.innerHTML property. The UI is done, and I now want to post back the user's changes and update my business object in .NET. But when I postback, I can't see any of my dynamically created HTML controls in VB .NET. How do I make them...
4
2716
by: assgar | last post by:
Hi I am stuck on a problem. I use 3 scripts(form, function and process). Development on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
2
3392
by: jmarendo | last post by:
Hello, After reading through the "Table Basics - DOM - Refer to table cells" example at mredkj.com , I modified the code for my own purposes. In the modified version, I create a hyperlink and place it in the last cell of each row that I create dynamically using DOM methods. Everything is working well (that is, just like the original example) except for something related to the function behind my link. The link simply calls a function...
21
29839
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays prodcut anme have used ajax to avoid refreshing of page this works fine 2.now i have created one row with checkbox|select box|text|text|text|text| where in the select box values are fetched from table here also i have used ajax for getting the m_name...
13
1527
by: Konrad Hammerer | last post by:
Hi! Can somebody tell me or show me an example how to add a textbox and a button dynamically by code to an apsx page and how to read the filled in value from the textbox after the user has clicked the button? I have tried this without success because after the user has clicked the button, the textbox seems to be disappeard! I have added it to a placeholder and tried to read it with ctype(placeholder1.controls.item(0),textbox).text,...
2
4056
by: gubbachchi | last post by:
Hi, I have a form whose elements are created dynamically on selection, i.e. the form has only text boxes and the number of text boxes depends on the users selection, if user selects 3 then 3 dynamic text boxes are created and if user selects 4 then 4 dynamic text boxes are created and so on. Here is the code I am using to dynamically create the text boxes: echo ("<form name='exam' action='exam_2.php' method='POST'>"); for...
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.