JavaScript - How To Get The Dynamically Created Text Box Values
Hi Peers,
i have a button that helps me creating more than one dynamic text box and dropdownlist... how it possible to capture the values in those dynamic comtrols ? i am trying the following but did not work ..when the code is excuted it gives me [object] // Create Text box 1 var newStartDate = document.createElement('input'); newStartDate.setAttribute("type","date"); newStartDate.size=8; //capture the value in a temp variable val1 var val1 = document.getElementsByName(newStartDate); alert(val1); the alert gives [object] thanks Similar TutorialsHi Experts, i'am able create dynamically 2 text boxes ( start date & End Date) . Also i am able to create dynamically (img) calendar gif pictures beside each textbox. What i am stuck on is how to popup a calendar while clicking on the img and assign the date to a dynamic texboxes... Any help is much appreciated.. thank you here is the part of my code : // Create Start Date Text box var newStartDate = document.createElement('input'); newStartDate.setAttribute("type","date"); newStartDate.size=8; // Create calendar 1 img var newCalImg1 = document.createElement('img'); newCalImg1.src = "../media/forms/cal.gif"; // Create End Date Text box var newEndDate = document.createElement('input'); newEndDate.size=8; // Create calendar2 img var newCalImg2 = document.createElement('img'); newCalImg2.src = "../media/forms/cal.gif"; Hi, I am using a javascript datepicker which works fine with simple textboxes: For example: I have a textBox startDate1 in the table below: <form method="post" name="upload" action=""> <table id="tableId"> <tr> <td> <input type="text" name="startDate1" value="" readonly="true" size="10"/> <script language="JavaScript"> new tcal ({'formname': 'upload','controlname': 'startDate1'}); </script> <td> </tr> <table> </form> --Now I want to add rows dynamically to this table for which I have <a href="javascript:addRowToTable();" >Add Row</a> and the corresponding javascript function: <script type = "text/javascript"> function addRowToTable() { var tbl = document.getElementById('tableId'); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var box = row.insertCell(0); var element = document.createElement('input'); element.setAttribute('type', 'text'); element.setAttribute('name', 'startDate' + iteration); box.appendChild(element); } </script> --This code creates the text boxes properly, but I am not being able to add the datepicker to it. Please suggest me a way to add the datepicker to the textboxes in the dynamically generated rows. Thank You Regards Rusho Shaw I have an input box "product" besides it there is an add input button which adds another input box product upon clicking.This array of input boxes I have created is through document.createElement('input'). My autocomplete is working for the initial input box....now when I click add Input button for the generated box also the autocomplete shld work...how do I make it work?? PS:Autocomplete script is working so I didnt post it here.... I just want it to make it working dynamically created i/p boxes Hello, I'm trying to write a script for a website that reads from a database and makes a separate table for each entry in the database. Since the number of entries can change, I want to dynamically create a div for each one, which I can later hide or display based on user selection. However, when I try to access the dynamically created elements by their ID, they return null. Is what I'm trying to do here actually possible? Code: for(var i = 0; i < tables.length; i ++) { var newDiv = document.createElement("div"); newDiv.setAttribute("id", tables[i].name); newDiv.setAttribute("name", tables[i].name); newDiv.setAttribute("class", "hidden"); newDiv.innerHTML += tables[i].name; newDiv.innerHTML += "<table id = 'table"+tables[i].name+"' border = '1'>"; newDiv.innerHTML += "<tr>"; for(var rows = 0; rows < table.arrayOfFields.length; rows++) { newDiv.innerHTML+="<th>"+table.arrayOfFields[rows].title+"</th>"; numOfEntries = table.arrayOfFields[rows].arrayOfEntries.length; } newDiv.innerHTML+="<tr>"; for(var cols = 0; cols < numOfEntries; cols++) { for(var rows = 0; rows < table.arrayOfFields.length; rows++) { newDiv.innerHTML+="<td>"+table.arrayOfFields[rows].arrayOfEntries[cols].data+"</td>"; } newDiv.innerHTML+="<tr>"; } newDiv.innerHTML+="</table>"; document.body.appendChild(newDiv); } Hi all , i am creating a dynamic controls but one thing iam stack on is how to associate an existing class ("C1") to that dynamic control : i.e var var1 = row.insertCell(0); var1.align ="center"; var1.innerHTML - array1[A1[i]]; thoughts ? thanks I have the following code which adds a dynamically created textbox to a form: Code: function addarow() { if (count > 5) {return false} count ++; addbox = '<input type = "text" name = "txt1" id = "txt1" class = "box">'; document.getElementById("boxes"+count).innerHTML = addbox + "<br>"; } I am having difficulties in assigning different names/ids to the sequential textboxes, that is "txt"+count to give txt1, txt2 etc. Your assistance will be much appreciated. A child of five would understand this. Send someone to fetch a child of five. Groucho Marx I'm having an issue adding focus() to an input that is dynamically created with jquery. I'm still learning, so I've mixed in traditional js with my jquery code because it's easier for me to understand. Anyhow document.getElementById(name).style.backgroundColor="#72A4D2"; successfully changed the background of the input ID, but document.getElementById(name).focus(); does nothing. I know that this is the correct code because if I hard code an input into the form (which you can see I've commented out below, such as document.getElementById('password').focus(); it refocuses successfully on that input. Thus I'm stumped yet again. Anyone know how to deal with this issue? JS: Code: $(function() { var i = $('input').size() + 1; $('a.add').click(function() { $('<p>Username ' + i + ': <input type="text" id="user' + i + '" name="user' + i + '" onblur="javascript:checkl(this.name, this.value);"></p>').animate({ opacity: "show" }, "slow").appendTo('#inputs'); i++; }); }); function checkl(name, value){ var errors=new Array(); var x; var msg = "There were some problems...\n"; if (value==="") { errors['blank'] = "Field must not be blank"; } for (x in errors) { msg += "\n"+errors[x]; } if (!(x==undefined)){ alert(msg); document.getElementById(name).style.backgroundColor="#72A4D2"; //works, changed input background successfully document.getElementById(name).focus(); // does NOT work, no focus // document.getElementById('password').focus(); // successfully refocuses on hard coded 'password' input }else{ document.getElementById(name).style.backgroundColor=""; } } HTML: Code: <a href="#" class="add" id="1"><img src="add.png" width="24" height="24" alt="add" title="add input" /></a> <form id="target" name="target" action="post.php" method="post" onsubmit="return validate(this);"> <div id="inputs"> <!-- dynamically created inputs here --> </div> <!-- Password: <input type="password" id="password" name="password" size="10"> --> <input type="submit" value="Send"> </form> Hi, This is my first time here so I hope I'm not posting to the wrong forum. If this has been answered before, please direct me to the corrent post. I've created several dynamic checkboxes with with following code: <code> var pnl = document.getElementById("pnlSalesPeople"); for (i = 0; i < sales.length; i++) { var ck = document.createElement("input"); ck.type = "checkbox"; ck.id = "ck" + i; //ck.checked = true; var label = document.createElement('label'); label.htmlFor = ck.id; label.id = "label" + i; label.appendChild(document.createTextNode(sales[i])); pnl.appendChild(ck); pnl.appendChild(label); pnl.appendChild(document.createElement('<br />')); } </code> All the checkboxes get put into the panel, one per line, as expected. However, clicking on any of them does not change their checked state--if I uncomment the line setting the state above, all the checkboxes are checked, but they don't become unchecked when clicking on them. I'm thinking I'm missing something that will make these checkboxes behave like they should or my approach to dynamic creation is flawed. In any event, my knowledge of Javascript is certainly not at expert level so I'm hoping there might a simple solution to my dilemma. Any help on this is genuinely appreciated. TIA Hi. I've dynamically created some divs, how do I select a specific div to use? Code: //create box for length of letters in word var i = 0; for(i=0;i<wL;i++){ cBoxes = document.createElement("div"); cBoxes.className = "letterBoxes"; hangMan.appendChild(cBoxes); } So I'm creating the amount of divs equal to the amount of letters in my word (I'm making a hangman game). On correct guess, I need the letter to show in it's correct position (within the correct blank div previously created). I have the correct position stored in a variable (letPos), and the correct guess (userGuess), I need to show userGuess at the div equal to letPos, ie div 4 or div 5, etc. If I simply go cBoxes.innerHTML = userGuess, the correct userGuess always shows at the last position in my cBoxes divs. I need it to show at the correct position (letPos). Any hints? im trying to create a script for greasemonkey (tried getting help from their discussion forums, but no one ever answers), but its still written in javascript. so here is what im trying to do. Ive got a dynamically created division that aligns to the right of the browser window. Now im trying to put links inside it as you normally would with like a document.write statement or other methods. The only problem is, any method i try wont work for me. heres my code, maybe someone could give me some things i could try. Code: function QuickLinks() { var body = document.body; var div2 = document.createElement("div"); div2.setAttribute('class','QL'); div2.setAttribute('style','background-color: #692510;width: 200px;height: 500px;top: 2cm;position: absolute;right: 5px;z-index: 4;'); var links = document.createTextNode("where i want my links"); //now with that statement it just writes text, ive tried document.write and many other methods and nothing seems to work. div2.appendChild(links); //this just inserts the links into the div. body.appendChild(document.createElement('br')); body.appendChild(div2); } QuickLinks(); Hi all, I have a set or icons that which over time I replace with a different icon and and add a onclick event to them. This is my code Code: function updateStatusIcons(retText) { updatingStatuses = true; var updates = retText.split("|"); for (z=0; z<updates.length; z++) { var sysId = trim(updates[z].split(":")[0]); var projectId = trim(updates[z].split(":")[1]); if (projectId != "") { var statusImg = getSysidsImg(sysId); statusImg.src = "images/tick.gif"; statusImg.className = "hand"; statusImg.title = "Project "+ projectId +" created, Click here to find in project search"; statusImg.onclick = function () { document.location = "projectSearch-FTTC.jsp?initAction=loadproject&projectId="+ projectId; }; // Remove sysid from csv removeSysidfFromCSL(sysId); } } if (pollingOn) { pollingupdate = setTimeout("checkForProjectComplete()", 5000); } updatingStatuses = false; if (runErrorFunction) { markErrors(); } } Everything works fine except for the onclick event. In the hover message of the icon, the correct project ID is displayed in the message, hoever in the function, the onclick funtion always loads the page with the last set project id. How can I pass the project id into the onclick function and make it stay fixed and not be the value of that it was last set to? TIA, Dale Hello, I am trying to save a dynamically created anchor's id onclick, but I am having a lot of trouble. Code: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> </style> </head> <body onload="initAll();"> <div id="test"></div> <script type="text/javascript"> var xhr = false; //global xhr variable var allRequestIds = new Array(); var allRequestDates = new Array(); var allRequestNames = new Array(); var allRequestBriefs = new Array(); var allListLinks = new Array(); var allListItems = new Array(); var linkId; //global variable for clicked link's id; set to be the same as xml data's id; used to pull more data in next page function initAll(){ if (window.XMLHttpRequest){ //initialize xmlhttprequest into xhr variable xhr = new XMLHttpRequest(); } else{}//ie stuff goes here xhr.open("GET","xml/request.xml",true); //open connection xhr.onreadystatechange=createLinks; //onreadystatechange call createLinks() xhr.send(null); } function createLinks(){ if(xhr.readyState==4){ if(xhr.status==200){ if(xhr.responseXML){ var allRequests=xhr.responseXML.getElementsByTagName("request"); //save all requests into array var newList=document.createElement("ol"); //create a new ordered list for(i=0;i<allRequests.length;i++){ //arrays of each tag, and an array of links allRequestIds[i]=allRequests[i].getElementsByTagName("requestId")[0].firstChild.nodeValue; allRequestDates[i]=allRequests[i].getElementsByTagName("date")[0].firstChild.nodeValue; allRequestNames[i]=allRequests[i].getElementsByTagName("name")[0].firstChild.nodeValue; allRequestBriefs[i]=allRequests[i].getElementsByTagName("brief")[0].firstChild.nodeValue; allListLinks[i]=document.createElement("a"); //create an array of links allListLinks[i].appendChild(document.createTextNode(""+allRequestDates[i]+" "+allRequestNames[i]+" "+allRequestBriefs[i]+"")); //i don't know how to add a new line within createtextnode!!! wtf?! i wanted to add a <br /> allListLinks[i].setAttribute("href","somepage.html"); allListLinks[i].setAttribute("class","dynamicLink"); allListLinks[i].setAttribute("onclick","pullDetailed();"); allListItems[i]=document.createElement("li"); //create an array of list items allListItems[i].appendChild(allListLinks[i]); //append each anchor into each list item newList.appendChild(allListItems[i]); //append all list items into ordered list } document.getElementById("test").appendChild(newList); //append list into test paragraph } } } } function pullDetailed(){ alert("function pullDetailed called!"); //this is just testing to see if this function has been called on anchor click linkId=this.innerHTML.; //this doesn't work alert(linkId); } </script> </body> </html> does anybody have an ideas? thank you. Below I have dynamical generated radio buttons, the names($approve variable is the name) per radio button pairs are different(dynamically created names using looping). When I create two buttons, one is for if you click it, all the radio button with the label approve will be selected all, and the other button is for the disapprove label button that will select the radio button with the label disapprove. How can I make this right. Below are the codes I created. Thanks Code: <script> function selectAll() { var i = 0; objElems = document.t4.elements; for(i=0;i<objElems.length;i++){ objElems[i].checked =true; } </script> PHP Code: <form action="viewall.php" method="post" name="t4"> while(condition) { echo "<td ><input type='radio' name='". $approve."' id='app' value='approve' /> Approve<br /> </td> <td ><input type='radio' name='". $approve."' id='disp' value='disapprove' /> Disapprove<br /> </td> "; } <tr><td><input type="button" name="all_app" value="Select All Approve" onclick="selectAll(this.value);" ></td> <td><input type="button" name="all_app2" value="Select All disapprove" onclick="selectAll(this.value);" ></td> </tr> </form> I'm building a t-shirt shop whose interface includes a gallery of designs in an IFrame. When the user clicks on a design, a dedicated page is loaded into the IFrame which shows all the available products associated with the design the user clicked. I've put each design's image and associated page as the first and second elements of a nested array, and am using a for loop to then load all the images into the page that's shown in the IFrame when the web-site loads. It's looking beautiful, but here's the rub I've been stuck on for two days now with no solution in sight... The array, "designImages", has 37 elements (ie. designImages[0]... designImages[36]). When I click on a design image on the page, any design image, the browser (all browsers, so I can't blame Microsoft for this one ), loads the page for design #36. I've tried all sorts of things, but still cannot tell if the issue is because the dynamically generated divs are being reassigned the value [36] after the for loop's executed, or if the div id's are okay but somehow the code is rooting for [36], the last element of the array anyway. I need someone's help in enabling a click on #4 to load the page for #4, etc, etc. Here's the code below. Thanks. Code: /* designImages[x][0] = the image source on the page; * designImages[x][1] = the destination url on clicking the image; */ var designImages = new Array(); designImages[0] = new Array ( "Assets/DesignImages/Img00 - CosmicCircle.png" , "ProductGalleries/Img00.html" , "Cosmic Circles" , "Mark Lavin"); designImages[1] = new Array ( "Assets/DesignImages/Img01 - Flora.png" , "ProductGalleries/Img01.html" ); designImages[2] = new Array ( "Assets/DesignImages/Img02 - JBuddha.png" , "ProductGalleries/Img02.html" ); designImages[3] = new Array ( "Assets/DesignImages/Img03 - Ohm+Sun.png" , "ProductGalleries/Img03.html" ); designImages[4] = new Array ( "Assets/DesignImages/Img04 - Ohm+Burst.png" , "ProductGalleries/Img04.html" ); designImages[5] = new Array ( "Assets/DesignImages/Img05 - Space+Invader.png" , "ProductGalleries/Img05.html" ); designImages[6] = new Array ( "Assets/DesignImages/Img06 - Fire.png" , "ProductGalleries/Img06.html" ); designImages[7] = new Array ( "Assets/DesignImages/Img07 - Live.png" , "ProductGalleries/Img07.html" ); designImages[8] = new Array ( "Assets/DesignImages/Img08 - Being.png" , "ProductGalleries/Img08.html" ); designImages[9] = new Array ( "Assets/DesignImages/Img09 - Water.png" , "ProductGalleries/Img09.html" ); designImages[10] = new Array ( "Assets/DesignImages/Img10 - Abundance.png" , "ProductGalleries/Img10.html" ); designImages[11] = new Array ( "Assets/DesignImages/Img11 - Adventure.png" , "ProductGalleries/Img11.html" ); designImages[12] = new Array ( "Assets/DesignImages/Img12 - Air.png" , "ProductGalleries/Img12.html" ); designImages[13] = new Array ( "Assets/DesignImages/Img13 - Chance.png" , "ProductGalleries/Img13.html" ); designImages[14] = new Array ( "Assets/DesignImages/Img14 - Dangerous.png" , "ProductGalleries/Img14.html" ); designImages[15] = new Array ( "Assets/DesignImages/Img15 - Destiny.png" , "ProductGalleries/Img15.html" ); designImages[16] = new Array ( "Assets/DesignImages/Img16 - Dream.png" , "ProductGalleries/Img16.html" ); designImages[17] = new Array ( "Assets/DesignImages/Img17 - Earth.png" , "ProductGalleries/Img17.html" ); designImages[18] = new Array ( "Assets/DesignImages/Img18 - Ecstasy.png" , "ProductGalleries/Img18.html" ); designImages[19] = new Array ( "Assets/DesignImages/Img19 - Freedom.png" , "ProductGalleries/Img19.html" ); designImages[20] = new Array ( "Assets/DesignImages/Img20 - Friendship.png" , "ProductGalleries/Img20.html" ); designImages[21] = new Array ( "Assets/DesignImages/Img21 - Fulfillment.png" , "ProductGalleries/Img21.html" ); designImages[22] = new Array ( "Assets/DesignImages/Img22 - Generosity.png" , "ProductGalleries/Img22.html" ); designImages[23] = new Array ( "Assets/DesignImages/Img23 - Gift.png" , "ProductGalleries/Img23.html" ); designImages[24] = new Array ( "Assets/DesignImages/Img24 - Imagine.png" , "ProductGalleries/Img24.html" ); designImages[25] = new Array ( "Assets/DesignImages/Img25 - Joy.png" , "ProductGalleries/Img25.html" ); designImages[26] = new Array ( "Assets/DesignImages/Img26 - Kinky.png" , "ProductGalleries/Img26.html" ); designImages[27] = new Array ( "Assets/DesignImages/Img27 - Mystery.png" , "ProductGalleries/Img27.html" ); designImages[28] = new Array ( "Assets/DesignImages/Img28 - Mastery.png" , "ProductGalleries/Img28.html" ); designImages[29] = new Array ( "Assets/DesignImages/Img29 - Peace.png" , "ProductGalleries/Img29.html" ); designImages[30] = new Array ( "Assets/DesignImages/Img30 - Sexy.png" , "ProductGalleries/Img30.html" ); designImages[31] = new Array ( "Assets/DesignImages/Img31 - iBurn.png" , "ProductGalleries/Img31.html" ); designImages[32] = new Array ( "Assets/DesignImages/Img32 - PlayaTrash.png" , "ProductGalleries/Img32.html" ); designImages[33] = new Array ( "Assets/DesignImages/Img33 - Ohm+Burst.png" , "ProductGalleries/Img33.html" ); designImages[34] = new Array ( "Assets/DesignImages/Img34 - BlackRockCity.png" , "ProductGalleries/Img34.html" ); designImages[35] = new Array ( "Assets/DesignImages/Img35 - BarCode.png" , "ProductGalleries/Img35.html" ); designImages[36] = new Array ( "Assets/DesignImages/Img36 - NumberedBarCode.png" , "ProductGalleries/Img36.html" ); window.onload = function() { creationCompleteHandler(); } function creationCompleteHandler() { calcNumDesigns(); setLinks(); } function calcNumDesigns() { var numDesignBoxes = designImages.length; var numGalleryRows = Math.ceil( numDesignBoxes / 3 ); for ( n = 0 ; n <= numGalleryRows - 1 ; n++ ) { var newGalleryBox = document.createElement('div'); var newGalleryBoxID = ("galleryRow" + n); newGalleryBox.setAttribute('id',newGalleryBoxID); newGalleryBox.setAttribute('class',"galleryBox"); document.getElementById('content').appendChild(newGalleryBox); squareOff(newGalleryBox); var rowBoxes; if ( ( numDesignBoxes - ( n * 3 ) ) < 3 ) { rowBoxes = ( numDesignBoxes - ( n * 3 ) - 1 ) } else rowBoxes = 2; for ( m = 0 ; m <= rowBoxes ; m++ ) { var boxNum = ( n * 3 ) + m; var newDesignBox = document.createElement('div'); var newDesignBoxID = "design" + boxNum; newGalleryBox.appendChild(newDesignBox); newDesignBox.setAttribute('id',newDesignBoxID); newDesignBox.setAttribute('class',"designBox"); var newDesignImg = document.createElement('img'); var newDesignImgID = "designImg" + boxNum; newDesignImg.setAttribute('id',newDesignImgID); newDesignImg.setAttribute('class',"designImage"); newDesignImg.src = designImages[boxNum][0]; newDesignBox.appendChild(newDesignImg); } } } function squareOff(frame) { document.getElementById(frame.id).style.height = ((document.getElementById(frame.id).offsetWidth) * .33) + 'px'; } function setLinks() { for (x in designImages) { document.getElementById("design"+x).onclick = function(){ sendToURL(x) } }; } function sendToURL(x) { var url = designImages[x][1] MM_goToURL('self',url); return document.MM_returnValue; } function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } I'd like to create a basic form where 3 text input fields are named with the following names referrerId, referrerId2 & referrerId3. My goal is once the text fields within the form are populated with the users data, then once the user clicks submit, a new browser window opens up (in parent window preferably), navigating to the following url exactly as shown. Highlighted in red is the dynamic information I'd like appended. Vacation Packages &referrerId=FIRSTNAME&referrerId2=LASTNAME&referrerId3=AGENTNUMBER Any help would be greatly appreciated. Thanks! Hi gud mng, I have one problem... How to process textbox values/ call textbox values in JS through a Java program. My text box values are dates. I have to process these dates. Like in online banking we select day to know our transactions. After submitting we get results. remember my files are in my directory only. No need of database. My files are look like 20100929, 20100930, 20101001 For epoch_classes.js, epoch_styles.css u can download coding from this link : http://www.javascriptkit.com/script/...ch/index.shtml Code: Code: <html> <table width="900" border="0" cellpadding="10" cellspacing="10" style="padding:0"> <tr><td id="leftcolumn" width="170" align="left" valign="top"> <div style="margin-left:0px;margin-top:0px"><h3 class="left"><span class="left_h2">Select Option</span></h3> <a rel="nofollow" target="_top" href="day_wise.htm" >Day-wise</a><br /> <br /> <a rel="nofollow" target="_top" href="between.htm" >Between Days</a> <link rel="stylesheet" type="text/css" href="epoch_styles.css" /> <script type="text/javascript" src="epoch_classes.js"></script> <script type="text/javascript"> var cal1, cal2; window.onload = function () { cal1= new Epoch('epoch_popup','popup',document.getElementById('popup_container1')); cal2= new Epoch('epoch_popup','popup',document.getElementById('popup_container2')); }; /*............*/ function confirmation(f) { var startdate = f.fromdate.value var enddate = f.todate.value var myday=new Date() var yr=myday.getFullYear() var mn=myday.getMonth()+1 var dt=myday.getDate() var today="" var present, ys, ms, ds, ye,me,de, start, end if(mn < 10) { mn = "0" + mn } if(dt <10) { dt = "0" + dt } today= yr + "/" + mn + "/" + dt present=yr + "/" + mn + "/" +dt if (today < startdate ) { alert (" Start date should not be exceed to-day's date " + present ) startdate.focus() return false } if (today < enddate ) { alert (" End date should not be exceed to-day's date " + present ) enddate.focus() return false } if (today == startdate ) { alert(" You are selected to-days date as Starting day" ); } var answer = confirm("Do you want to continue ?") if (answer) { if( startdate < enddate) alert("Dates between " + startdate + " to " + enddate + " are confirmed" ) else alert("Dates between " + enddate + " to " + startdate + " are confirmed" ) } else { alert("Date not confirmed") window.location="to_date.htm"; } ys= startdate.substring(0,4); ms= startdate.substring(5,7); ds= startdate.substring(8,10); start=ys + "" + ms + "" +ds ye= enddate.substring(0,4); me= enddate.substring(5,7); de= enddate.substring(8,10); end=ye + "" + me + "" +de } /*.......................................................*/ </script> <div style="margin-left:100px;"> <body> <style type="text/css"> #conf { margin-left:115px; } </style> <td align="left" valign="top"> <table width="100" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:0px"> </table> <h4>From Date</h4> <form name= "formbet" id="placeholder" method="post" action="#" > <input id="popup_container1" type="text" name= "fromdate" maxlength="10" size="20"/> <td align="left" valign="top"> <table width="300" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:20px"> <h4>To Date</h4> <input id="popup_container2" type="text" name= "todate" maxlength="10" size="20"/> <br /> <br /> <input id="conf" type="button" onclick="confirmation(this.form)" value="Submit"> </form> </body> </html> In my coding, ys, ms, ds represents year starting, month starting, starting day... ye, me, de represents end... start,end gives file names in the format of yyyymmdd now i want to process files from 20100101 to 20100930 means from date is 2010/01/01 and to date is 2010/09/30 if i press submit button the files from 20100101 to 20100930 are processes here ys=2010 ms=01 ds =01 and ye=2010 me=09 de= 30 For this how do i call these textbox values (from date text box and todate) to another program (java) Thanks in advance. Hello, I am trying to get something to work and I am not having any luck. I want to dynamically add a set of fields to a table when when the user onBlur the selection drop-down. I want the cursor to be in the text field of the newly added set. I have been playing around with onfocus function on the hyperlink to see if when focus is gained, it would throw the user into the text field. I am getting the impress that the field has not been created yet, so the getElementbById function cannot find the object just recently created. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title></title> <script language="JavaScript"> function addEvent() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById("theValue").value -1)+ 2; numi.value = num; var divIdName = "my"+num+"Div"; var newdiv = document.createElement('div'); newdiv.setAttribute("id",divIdName); newdiv.innerHTML = '<div>'+ num +'</div><div class=name><input class=name id=item-' + num + ' type=text name=item-'+ num + '></div><div><select name=selRow-' + num + ' onBlur="addEvent();"><option value="0">Check</option><option value="1">Cash</option><option value="2">Money Order</option><option value="3">EFT</option></select></div>'; ni.appendChild(newdiv); } function setTxtFocus() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById("theValue").value -2)+ 2; document.getElementById('item-' + num).focus; } </script><style type="text/css"> @import url(style.css); </style> </head> <body onload="addEvent();"> <div id=image></div> <form action=process.php method=post> <input type="hidden" value="0" id="theValue" /> <div id="myDiv"></div> <p><a href="javascript:;" onclick="setTxtFocus();">Add Other Suggestion</a></p> <p><input type=submit id="submitbutton" value=Submit disabled> <INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"></p> </form> </body> </html> Thanks jlimited I'm using Kevin Roth's Cross-Browser Rich Text Editor JS component. Below is a demo.php script showing how it's created in JS. I got it working fine but I now want to dynamically add new text to the component in my php script. I know how to setup the php part to initiate the new text load event but I can't figure out how to actually get the new text into the RTE component inside a JS function. I tried this JS function but it didn't load in the new text in: PHP Code: function pre_canned_message_click() { rte1.html = 'New string'; } In the demo.php below the RTE component is loaded the same way rte1.html = but in the JS function it doesn't work. I don't know what I'm missing here. Thanks for any help... PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php echo var_dump($_POST); ?> <!-- // Cross-Browser Rich Text Editor // Written by Kevin Roth (http://www.kevinroth.com/rte/) // License: http://creativecommons.org/licenses/by/2.5/ //--> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Cross-Browser Rich Text Editor (RTE)</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="cross-browser rich text editor, rte, textarea, htmlarea, content management, cms, blog, internet explorer, firefox, safari, opera, netscape, konqueror" /> <meta name="description" content="The cross-browser rich-text editor (RTE) is based on the designMode() functionality introduced in Internet Explorer 5, and implemented in Mozilla 1.3+ using the Mozilla Rich Text Editing API." /> <meta name="author" content="Kevin Roth" /> <meta name="ROBOTS" content="ALL" /> <!-- html2xhtml.js written by Jacob Lee <letsgolee@lycos.co.kr> //--> <script language="JavaScript" type="text/javascript" src="../cbrte/html2xhtml.min.js"></script> <script language="JavaScript" type="text/javascript" src="../cbrte/richtext_compressed.js"></script> </head> <body> <h2>Cross-Browser Rich Text Editor (RTE) Demo</h2> <p>For more information, visit the <a href="http://www.kevinroth.com/rte/">Cross-Browser Rich Text Editor (RTE) home page</a>.</p> <!-- START Demo Code --> <form name="RTEDemo" action="demo.php" method="post" onsubmit="return submitForm();"> <script language="JavaScript" type="text/javascript"> <!-- function submitForm() { //make sure hidden and iframe values are in sync for all rtes before submitting form updateRTEs(); return true; } //Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML) initRTE("../cbrte/images/", "../cbrte/", "", true); //--> </script> <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript> <script language="JavaScript" type="text/javascript"> <!-- //build new richTextEditor var rte1 = new richTextEditor('rte1'); <?php //format content for preloading if (!(isset($_POST["rte1"]))) { $content = "here's the " . chr(13) . "\"preloaded <b>content</b>\""; $content = rteSafe($content); } else { //retrieve posted value $content = rteSafe($_POST["rte1"]); } ?> rte1.html = '<?=$content;?>'; //rte1.toggleSrc = false; rte1.build(); //--> </script> <p><input type="submit" name="submit" value="Submit" /></p> </form> <?php function rteSafe($strText) { //returns safe code for preloading in the RTE $tmpString = $strText; //convert all types of single quotes $tmpString = str_replace(chr(145), chr(39), $tmpString); $tmpString = str_replace(chr(146), chr(39), $tmpString); $tmpString = str_replace("'", "'", $tmpString); //convert all types of double quotes $tmpString = str_replace(chr(147), chr(34), $tmpString); $tmpString = str_replace(chr(148), chr(34), $tmpString); // $tmpString = str_replace("\"", "\"", $tmpString); //replace carriage returns & line feeds $tmpString = str_replace(chr(10), " ", $tmpString); $tmpString = str_replace(chr(13), " ", $tmpString); return $tmpString; } ?> <!-- END Demo Code --> </body> </html> Hi Guys, I am new to this forum,based on the combobox value,I am creating a textboxes dynamically in jsp .Based on the count of textboxe's the textarea content comes with <value1> like this... Here i tried like this, <html> <head> <script> function copy_data(val,id,textareaValue){ var enteredText = val; alert("enteredText -----------"+enteredText); var boxId= id; alert("boxId-----------"+boxId); var textValue= textareaValue; alert("textValue-----------"+textValue); var beforeBrac = textValue.substring(0,textValue.indexOf("<")); alert("beforeBrac -----------"+beforeBrac ); var inbracket = textValue.substring(beforeBrac.length+1,textValue.indexOf(">")); alert("inbracket -----------"+inbracket); if(boxId = "1"){ inbracket = val; } alert("inbracket -----------"+inbracket); var afterBrac = textValue.substring(textValue.indexOf(">"),textValue.length); alert("afterBrac -----------"+afterBrac ); var fstr = beforeBrac +"<"+inbracket +afterBrac ; if(boxId == "1"){ document.getElementById('txtArea').value = fstr; alert("final str value is"+fstr); } } </script> </head> <body> <input type="text" name ="a" id="1" onkeyup="copy_data(this.value,this.id,document.getElementById('txtArea').value)"/> <input type="text" name ="a" id="2" onkeyup="copy_data(this.value,this.id, document.getElementById('txtArea').value)"/> <textarea rows="2" cols="20" id="txtArea"> At W3Schools you <will> find all <the> Web-building tutorials <you> need, from basic HTML to advanced <XML>, SQL, ASP, and PHP. </textarea> </body> </html> three text boxes with some value [ value1 ] [value2] [value3 ] this is the text area content:- At W3Schools you <will> find all <the> Web-building tutorials <you> need, from basic HTML to advanced XML, SQL, ASP, and PHP. the output should be :- At W3Schools you <value1> find all <value2> Web-building tutorials <value3 > need, from basic HTML to advanced XML, SQL, ASP, and PHP... But i can't get it exactly..When i enter or delete the value it should replaced in the proper <> correctly.. If i enter the value in 1st textbox it should replace the value 1st <>.same for others also...Any Idea's ?Plz suggest me ... |