JavaScript - Manipulate Array Input
Hi
I have problem to manipulate my form with array. I want to copy my input from one input to other input but it didnt work. i did explore the usage of document.myForm.feed[3].value but it gave me error. Pleaseee help? Thanks script sample: <form name=myForm> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=feed[] onBlur=duplicate(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> <input name=copier[] onBlur=sendback(this)> </form> <SCRIPT> function duplicate(info) { //this function should copy 'info' to copier input //with the same element location //eg: feed[3] will copy to copier[3], feed[5] will copy to copier[5] //(can be any element insert by user) // the task would be: // 1. to get which element number has been inserted // 2. to get the origin text value // 3. to write the same element position for copier } function sendback(info) { //this function should copy 'info' to feed input //with the same element location //copier[2] will copy to feed[2], copier[3] will copy to feed[3] //(can be any element insert by user) } </SCRIPT> Similar TutorialsHi, i have an input value array for customer ids, i also need to make a copy of that array into another input element on submit to use for another process. So far here is what i have come up with regarding the js the current html is this Code: <!-- original input --> <input id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $commissions[$i]['id'];?>" onclick="isChecked(this.checked);" type="checkbox" /> <!-- this is new html input which is outside the $i loop that i need a copy of cid[] stored on submit <input type="hidden" name="ids[]" onsubmit="valueTovalue();" /> <!-- here is the js so far --> <script type="text/javascript"> function valueTovalue() { var valin = document.adminForm.cid.value; //cid is the array cid[] document.adminForm.ids.value = valin; //copy the array to the new input element array ids } </script> so basically if they click 1 cid then ids will also show 1, if they click all cid then ids will show all as well. will that work the way i have it, am i even close here.. thanks update: what i have seems to work fine for text values or string values but not for arrays, what am i missing that it wont copy an array? Array ( [cid] => Array ( [0] => 1 ) [task] => remarksonly [remark] => hhhyyy [boxchecked] => 1 [ids] => Array ( [0] => ) ) am i getting closer lol Code: function valueTovalue() { var valin = cid.concat; document.adminForm.ids.value = valin.concat; return(true); this has to be close i hope Code: document.adminForm.ids.value = [].concat(document.adminForm.cid); Hey peeps, I'm trying to use wget to access this website that uses javascript. The website is from my work. Basically I made a program that parses information from our payment page. It tells me how much I am being paid for the month. Anywho, the variables on the page are in javascript, and thats one language I'm not proficient at. I need to change the month that it gets the pay for. The default is the current month. But it can be changed to last month, and from the code I can tell that something has to be changed from "THIS_MONTH" to "LAST_MONTH", but I'm not sure how to properly do it. Posted below is the source code from the website. Please let me know how I can change that without actually having to click the button to change the scope to last month. And also, is there any way to change this in the post method, or any other method that wget uses? I only included the parts I thought could be relevant. Thanks guys! BTW, I think it pertains with g_FiltersMenuStr Code: <title>SupportSpace - Tech Support for Computers, Printer, Security, Gadgets...</title> <meta name = "description" content = "get immediate tech support for your PC / Computer, Printers, Outlook / Email Setup, Wireless, Networking, Anti-Virus & Security, Spyware, XP, Vista, I-Pod, MP3 Player Setup, Zune, Printer Setup, Backup Services for your Documents & Many other online live support"/> <meta name = "keywords" content = "online live tech support PC Computer Printers Outlook Email Setup Wireless Networking AntiVirus Security Spyware XP Vista IPod MP3 Player Zune Printer Setup Backup Services hardware software help chat"/> <meta name = "language" content = "English"/> <link REL="SHORTCUT ICON" HREF="/support/images//icons/shortcut_icon.ico"/> <script type="text/javascript">if(!JAWR){var JAWR = {};};;JAWR.jawr_dwr_path='/support/dwr';JAWR.dwr_scriptSessionId='CCA333F742C70F495236AA2C97D653D2';JAWR.app_context_path='/support';</script> <link rel="stylesheet" type="text/css" media="screen" href="/support/styles/31289092/bundles/common_connection.css" /> <link rel="stylesheet" type="text/css" media="screen" href="/support/styles/1893248551/bundles/sessionHistory.css" /> </head> <script type="text/javascript">if(!JAWR){var JAWR = {};};;JAWR.jawr_dwr_path='/support/dwr';JAWR.dwr_scriptSessionId='BF92335E3E86FC7586F1F5BFB96E81FB';JAWR.app_context_path='/support';</script> <script type="text/javascript" src="/support/scripts/122785183/bundles/common.js" ></script> <body class="supportspace"> <script type="text/javascript"> var jabberConnectorSrc = "/support/extra_scripts/1.23a1.6/flashconnector/jabberConnector.swf"; if (!!(window.attachEvent && !window.opera)){ document.write('\ <OBJECT id="jabberConnector" dontRewriteMe=true codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="1" width="1" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\ <PARAM value="'+jabberConnectorSrc+'" name="Src" />\ </OBJECT>'); } else{ document.write('<embed swliveconnect="true" name="jabberConnector" id="jabberConnector" src="'+jabberConnectorSrc+'" quality=low height="1" width="1" type="application/x-shockwave-flash"></embed>'); } </script> <!--[if lt IE 7]> <style> #dSSLogo{position:relative} </style> <![endif]--> <div id="dHeader"> <div id="dHeader_1" class="center s2DarkGray"> <div id="dSSLogo" onclick="document.location = 'http://www.supportspace.com/support/'"></div> <div class="rightLinks"> <div id="dHeaderLinks" style='display:none;' class='invisible'> <div class="dHeaderLink"><a class="mainlevel-trans" href="javascript:void(0);" id="dSigninMenu">Sign In</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="https://www.supportspace.com/support/affiliates.s2?aiu=UserRegistration" id="headerSecondMenu">Register</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="http://corporate.supportspace.com/about_us">About Us</a></div> <div class="dHeaderLinksSep">|</div> <div class="dHeaderLink"><a class="mainlevel-trans" href="http://www.supportspace.com/support/faq.s2" id="menuHelp">Help</a></div> </div> <div id="dHeaderLinksAfterLogin" class='visible'> <div id="dHeaderMailNotification"> <a id="nomailNotification" class="s2LightGray nounderline" href="http://www.supportspace.com/support/inbox.s2">(<span class="nbNewOfflineMessagesHeader">0</span>) <img src="/support/images/offline_messages/message_icon_grey_16x14.gif" alt="" title="" width="16" height="14" align="absmiddle" border="0"/></a> <a id="mailNotification" style="display:none" class="s2Blue nounderline" href="http://www.supportspace.com/support/inbox.s2">(<span class="nbNewOfflineMessagesHeader">0</span>) <img src="/support/images/offline_messages/message_icon_blue_16x14.gif" alt="" title="" width="16" height="14" align="absmiddle" border="0"/></a> </div> <div id="dHeaderWelcome" class="dHeaderWelcome">Hello </div> <div style="float:left;"> <table cellpadding=0 cellspacing=0 border=0> <tr> <td width="5">|</td> <td> <a id="dMySpaceMenu" class="mainlevel-trans" href="#">My Account</a> <ul id="dMySpaceMenuContent" class="menu" style="display:none;"></ul> </td> <td width="5">|</td> <td><a id="dSignOut" class="mainlevel-trans" href="http://www.supportspace.com/support/j_spring_security_logout">Sign Out</a></td> <td width="5">|</td> <td><a class="mainlevel-trans" href="http://corporate.supportspace.com/about_us">About Us</a></td> <td width="5">|</td> <td><a id="menuHelpAfter" class="mainlevel-trans" href="http://www.supportspace.com/support/faq.s2">Help</a></td> </tr> </table> </div> </div> </div> <div style="clear:both;"></div> </div> <div id="dHeader_2" class="center"> <div id="dHeaderMenus"> <div> <a href="http://www.supportspace.com/support/" onclick="this.blur()" title="SupportSpace homepage" tabindex="1" id="menuHome"> <img src="/support/images/header/home_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> <div> <a href="http://www.supportspace.com/support/expert" onclick="this.blur()" id="menuExperts" title="Search for online experts"> <img src="/support/images/header/experts_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> <div> <a href="http://www.supportspace.com/support/services" onclick="this.blur()" id="menuPackages" title="Search for featured support services"> <img src="/support/images/header/services_btn_regular.gif" alt="" width="127" height="32"/> </a> </div> </div> <div id="dSearchBox"> <div id="dSearchBoxQuery"> <input type="text" id="searchBoxQuery" style="color:#7C7C7C" name="searchBoxQuery" value="Search" onkeypress="submitEnter(this,event,runExternalSearch)"> </div> <div id="dSearchBoxGo"> <img id="dSearchBoxGoBtn" width="22" height="22" border="0" alt="Search" src="/support/images/header/search_icon_regular_22x22.gif" onmouseout="this.src='/support/images/header/search_icon_regular_22x22.gif'" onmouseup="this.src='/support/images/header/search_icon_regular_22x22.gif'" onmouseover="this.src='/support/images/header/search_icon_mouse_over_22x22.gif'" onmousedown="this.src='/support/images/header/search_icon_pressed_22x22.gif'" /> </div> <div style="clear:both;"></div> </div> </div> <div class="clearboth"></div> </div> <div id="dTemplateBody" class="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="leftPanel" > <div > <div class="getHelp box"> <div class="title"><img src="/support/images/header/menu_get_help.gif" width="170" height="27" alt="Get help on products"></div> <div class="s2Gray productList content"> <ul> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Virus_-_Spyware" title="Virus - Spyware">Virus - Spyware</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Printers" title="Printers">Printers</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/PC_Support" title="PC Support">PC Support</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Windows" title="Windows">Windows</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Security" title="Security">Security</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Backup" title="Backup">Backup</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/PC_to_PC_Transfer" title="PC to PC Transfer">PC to PC Transfer</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Wireless_Network" title="Wireless Network">Wireless Network</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Email_and_Internet" title="Email and Internet">Email and Internet</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Browsers" title="Browsers">Browsers</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/iPod_and_MP3" title="iPod and MP3">iPod and MP3</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Camera_-_Photo" title="Camera - Photo">Camera - Photo</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Mobile_Phones" title="Mobile Phones">Mobile Phones</a></li> <li class="product ellipsis"><a class="linkOnHover" href="http://www.supportspace.com/support/category/Green_PC" title="Green PC">Green PC</a></li> </ul> </div> </div> <div class="box howdoesitwork s2Gray"> <div class="title"> <img src="/support/images/left_pannel/menu_how_it_works_170x43.gif" width="170" height="43" alt=" "> </div> <div class="steps"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td><img src="/support/images/left_pannel/3_steps_1_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">1.Choose</span><br/> a service or an online expert.</p> </td> </tr> <tr height="5"></tr> <tr> <td><img src="/support/images/left_pannel/3_steps_2_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">2.Connect</span><br/> to the expert and watch your problem being solved.</p> </td> </tr> <tr height="5"></tr> <tr> <td><img src="/support/images/left_pannel/3_steps_3_icon_55x60.gif" width="55" height="60" alt=""/></td> <td valign="top"> <p><span class="title bold">3.Done</span><br/> Relax and rate your experience.</p> </td> </tr> </table> </div> </div> </div> </td> <td class="panelSpacer" > </td> <td class="rightPanel" > <div id="dBodyPage" class="bodyPage" > <script type="text/javascript" src="/support/scripts/N1461701270/bundles/session_history.js" ></script> <script type="text/javascript"> var gExternalParameterType = ""; var gSupportSessionId = ""; var gIsSupporter = true; var gError = false; var gExternalSessionFatalError = true; var gDefaultFilterList = {}; gDefaultFilterList['SESSION_DATE'] = ""; gDefaultFilterList['SESSION_STATUS'] = ""; gDefaultFilterList['SESSION_TYPE'] = ""; gDefaultFilterList['SUPPORT_SESSION'] = ""; gDefaultFilterList["SESSION_DATE"] = "THIS_MONTH"; gDefaultFilterList["SESSION_TYPE"] = "PAID"; var gSHistoryStrings = { error_feedback_add:"You cannot add feedback to this session.", error_feedback_fatal:"Required session is not availible. You cannot add feedback.", error_session_report_add:"You cannot edit the solution report for this session.", error_session_report_fatal:"Required session is not available. You cannot edit the solution report." } var g_FiltersMenuStr = { "SESSION_DATE":"Date", "SESSION_DATE.TODAY":"Today", "SESSION_DATE.YESTERDAY":"Yesterday", "SESSION_DATE.THIS_WEEK":"This week", "SESSION_DATE.LAST_WEEK":"Last week", "SESSION_DATE.THIS_MONTH":"This Month", "SESSION_DATE.LAST_MONTH":"Last month", "SESSION_DATE.LAST_6_MONTH":"Last 6 months", "SESSION_DATE.THIS_YEAR":"This year (2011)", "SESSION_DATE.LAST_YEAR_AND_EARLIER":"Earlier than (2011)", "SESSION_STATUS":"Status", "SESSION_STATUS.UNRESOLVED":"Unresolved", "SESSION_STATUS.ENDED_BEFORE_PAYMENT":"Ended before payment", "SESSION_STATUS.FORWARDED":"Forwarded", "SESSION_STATUS.DISPATCHED":"Dispatched", "SESSION_STATUS.RESOLVED":"Resolved", "SESSION_STATUS.UNCOMPLETED":"Uncompleted", "SESSION_STATUS.IN_PROGRESS":"In progress", "SESSION_STATUS.LEFT_OPEN":"Left Open", "SESSION_TYPE":"Type", "SESSION_TYPE.PAID":"Paid", "SESSION_TYPE.FREE_COUPON":"Free (Coupon)", "SESSION_TYPE.FREE_EXPERT":"Free (Expert)", "SUPPORT_SESSION":"Current Support Session", "DEFAULT_FILTER_MENU":"Back to default", "NO_FILTERS_MENU":"Clear all filters", "NO_FILTERS_NOTE":"No filters (All sessions)" }; var gSessionFeedbackHistoryUrl = "/support/sessionFeedbackHistory.s2"; var gSessionHistory = "/support/sessionHistory.s2"; var gSessionHistoryUrls = { filter_empty:"http://images.supportspace.com/support/images/common/empty.gif", filter_X:"http://images.supportspace.com/support/images/session_history/filter_X_mark.gif", filter_V:"http://images.supportspace.com/support/images/session_history/filter_V_select.gif", filter_arrow_white:"http://images.supportspace.com/support/images/session_history/filter_arrow_white.gif", filter_arrow_grey:"http://images.supportspace.com/support/images/session_history/filter_arrow_grey.gif" } var g_experts; </script> <div id="dSHistoryPage"> <div class="dSmallPreloaderContainer"><div id="dSmallPreloader" style="display:none;"><img src="http://images.supportspace.com/support/images//common/preloader_16x16.gif" alt=""></div></div> <h1 style="float:left">Session History</h1> <div class="clearboth"></div> <div id="dSHistoryContent"> <div id="dListBar" class="listBar"> <div id="dFiltersMenuButton">Filtered by: <img src="/support/images/session_history/filter_arrow_down.gif" alt=""/></div> <div id="dFiltersSelected"></div> <div class="displayedCounter">Displaying: 38</div> </div> <div id="dFiltersMenuContent"><div id="dFiltersMenuDivToReplace"></div></div> <div class="clearboth"></div> <div id="dSHistoryResults"> <script type="text/javascript"> var gSelectedFilters = {}; gSelectedFilters['SESSION_DATE'] = ""; gSelectedFilters['SESSION_STATUS'] = ""; gSelectedFilters['SESSION_TYPE'] = ""; gSelectedFilters['SUPPORT_SESSION'] = ""; gSelectedFilters["SESSION_DATE"] = "THIS_MONTH"; gSelectedFilters["SESSION_TYPE"] = "PAID"; (function(){ var dDisplayedCounter = $("dListBar") ? $("dListBar").down(".displayedCounter") : null; if(dDisplayedCounter){ dDisplayedCounter.update("Displaying: 38"); } }).defer(); var gSolutionReport; </script> <div class="dThreads"> <div id="dSessionHistoryError" style="display:none;"></div> <script type="text/javascript"> if (typeof(window.g_experts) == "undefined" || !window.g_experts){ window.g_experts = []; window.gIsAnExpertIsOnline = false; } g_experts.push({ id:193037, supporterDynamicDetails:{ online4Customer:{ customer:{ id:"" }, customerCookie:"" }, supporterDisplayPresenceStatusForExpectedCustoemr:"online", supporterDisplayPresenceStatus:"online" }, displayUserName:"", jabberUsername:"23a9ea173c4a7923ef41c9d6afa208d36ea1900f", photoUri:"193037_1273126504113.gif" }); </script> Hi all, I have a newbie question. I have just started working with javascript and would appreciate some guidance. I have a webpage and there are products for sale on it(this is not live it is merely being used as practice project). Beside each product is a description a price and an 'add to cart' button. My cart is simply a div with an id of 'cart' and it has a text box within it. I need the product name to be displayed within the div (this, I have working), I also need to display the product price in the text box once the button(add to cart ) for that particular product has been pressed. Also when the button for another product is pressed, I want the cost/value for that product to be added to the other value and displayed in the text box in the cart div... I apologise for rambling on but this is the best way of me explaining my needs.... Here's where i am right now.. The HTML snippet Code: <div id ="cart"> <p><img src="images/shopping-cart.png" alt ="cart"/>Your Cart</p> <div id="sum"><!--(this is the div where the total goes)--> <input type="text" id="total" value="0" /><p>€ Your Total <input type="reset" value = "reset" /></p> </div> </div> <h2 id ="black">Blackcurrent<br /></h2> <p>€ 12.00 <input type = "submit" value ="add to cart" onClick = "shoppingCart('Blackcurrent',12)" /></p> And the javascript: Code: alert ("working"); function shoppingCart (itemName,itemValue) { /* var thePrice = Number(itemValue); return thePrice;*/ document.getElementById ("cart").innerHTML += itemName + "<br/>"; document.getElementById('total').value = Number(document.getElementById('total').value) + itemValue; } I hope i have posted correctly and am aware that i have only posted a segment of the HTML.. Please let me know if you need any more code or info.. Thanks a lot in advance for any help... Hello. I need to manipulate with a upper and lower case on STRINGS For example I have string: Code: LALA_KAKA_mama_WIWI I need to conwert it to Code: Lala_kaka_mama_wiwi with first letter upper case. Is it one simple way to do it with JS script/code? Best Regards Thanks again for answering my questions perfectly previously, this next one really tested my minimal coding knowledge, and bested me. Basically, what I need done is this: This is a form [This is a text Box] [This is a submit button] Users on my website will enter a URL into the text box and press submit. Upon pressing submit it will redirect them to a webpage based on what they inserted into the textbox, sounds easy. But this is where it gets complicated. I need to take out certain parts of the URL they entered and place them inside of another URL. Here is an example www.google.com/images/picture/Download77_75.html I need to take the words in BOLD and Itallics and insert them specifically into another URL. which they will be redirected to after pressing submit. so now redirect to www.Mywebsite.com/Download77-with/GIF/images Basically I have the original string, which like above would be www.Mywebsite.com/Italicized string-with/GIF/Bolded String The original redirect link would stay the same. And taking from what you entered into the form, it would take out the specific bits and add them into the specific bits into another URL and redirect to that URL. Please note that I believe this is only possible becuase the amount of characters between the strings will ALWAYS be the same based on the content that my users are putting into the submit box. I.E the string in the Italicized string will always be 10 characters long, and everything in the Bolded String will always be 8 characters long (Not really, just an example). So maybe the script could tell it to count characters and take out characters from characters 8-15 and characters 19-36 then place them in the specific spots and then redirect them to that compiled link. Thanks for ALL the help! This one really boggled my mind. I could not think of anything that would help. This forum has come out to be my BEST resource %100 of the time. If you could help me with this. I will be AMAZED. Thanks in advance! PS: It doesen't have to be in any particular code language, But I do prefer HTML and Javascript. hello, I have a text input box where users can input values separated by a line break. What I need to do is to take those values and put them all into an array once they hit "submit". I can do this one line at a time, but I would like to be able to do it all in one hit. Can it be done in javascript? thanks in advance... Hello everyone I am trying to receive the output of an array from a text input here is the code that I am attempting to do but it is not displaying the output January Here is the code example [CODE] <html> <script type ="text/javascript"> <!-- function coms(str){ var myArray = new Array(); myArray[0] = ["January"]; var index = 0; for(var i = 0; i < myArray.length; i++){ index; if(myArray[i] == "January"){ index i; } if(str.length == myArray[i]){ document.write(str); } } } </script> <body> <form> Panel:<input type="text" name="panel" onkeyup="coms(this.value)" /> <div id="read"><p>Data is displayed here</p></div> </form> </body> </html> [CODE] Any tips to make this possible are welcome thank you kindly i have tried searching the forums for help but really am getting no where. i am trying to call an array item from an input box. the input is all numbers. the arrays are v + numbers. i cannot seem to figure out how to get the item from the array. eg Code: var v00501 = ["HOLTSVILLE,I R S SERVICE CENTER","NY","631","-5","Y"] var v00544 = ["HOLTSVILLE,IRS SERVICE CENTER","NY","631","-5","Y"] var v00601 = ["ADJUNTAS,JARD DE ADJUNTAS,URB SAN JOAQUIN","PR","787/939","-4","N"] function pop() { var zipv = "v" + myform.Zip.value +"[0]"; alert(zipv); } or Code: function pop() { alert(pop1()); } function pop1() { return "v" + myform.Zip.value +"[0]"; } so for this if the user typed in 00501 i get v00501[0] no matter what i try. i want HOLTSVILLE,I R S SERVICE CENTER to be returned or whatever item i am calling for. this all has to be on client side as i dont have server access so the zip codes are all set up as arrays in a seperate file. i really dont know alot about javascript but i am learning. any help on how i can accomplish this would be appreciated. Hi, I'm struggling with all this DOM stuff so I hope someone can help. I have a form with multiple input fields and I'm trying to identify the specific input field that is in focus so that I can display a relevant status bar message. I have a message array with various entries in it and I'm calling a showStatus() function with an onfocus function from the form itself e.g. The code in the input form = Code: <input type="text" name="first" size="31" maxlength="20" class="entry" onfocus="showStatus()"/> The showStatus() function so far is = Code: function showStatus() { var message = ['Please provide your First Name.', plus loads of other properley formatted status messages......] var x=document.getElementById().focus(); window.status = message[x]; } I'd like to access the array variable of the item that is in focus not only for the message but also for an onblur function to validate input. Any ideas? My thanks R the title kind of sums it up... if I have an array of equations (I'm guessing they should be strings but they don't have to be) and a user-defined variable can that variable be used for the "x" in the equations? I already did the easy part ... Code: <!DOCTYPE html> <html> <head> </head> <body> <input onkeyup="solve(this.value)" /><br> <input id="box0" /><br> <input id="box1" /><br> <input id="box2" /><br> <script type="text/javascript"> var equations=["(x*9/5)+32","x+273.15","x-50*(8/13)"] function solve(val){ for (var i = 0; i < equations.length; i++) { document.getElementById("box"+i).value= //ummm... } } </script> </body> </html> Hi, what would be the best way to have a hidden array of possible text directed at a textarea and then if something is not within that array "onfocus", a certain select option is chosen within that form? Thanks I am thinking this should be fairly easy but yet I am not getting far. I want to have a form with a single text imput field for a zip code. Depending on which zip code the user enters will determine which url they will be sent to. If they enter a zip code which is not in the script, they would be sent to a default url. I am also assuming this can be accomplished with javascript. Any help is greatly appreciated. I have a problem with adding new inputs to a form (if and when required), Internet Explorer is fine but in Firefox if any previous input fields are filled when the more button is clicked they get reset to blank. JS: Code: fields = 0; function addInput() { if (fields != 100) { document.getElementById('input').innerHTML += "<input type='text' name='input[]' size='30' />"; fields += 1; } else { document.getElementById('input').innerHTML += "<br />Maximum 100 fields allowed."; document.form.add.disabled=true;} } form: Code: <form action="index.php" method="post"> <div id="input"> <input type="text" name="input[]" size="30" maxlength="15" /> </div> <!-- button --> <div id="more"> <input type="button" onclick="addInput()" name="add" value="More" /> </div> <!-- // button --> <input type="submit" name="submit" value="Submit" /> </form> as usual any help is appretiated .. Hi, i want to set an input value to the same value as the input selected from another input on the same form so when the user selects input 1 i want the hidden input2 to get the same value im guessing i use onsubmit because its hidden so there wont be a focus or blur this would be part of the input Code: onsubmit="(this.value = this.othervalue)" othervalue being the other input name="othervalue" is that the correct syntax Hi all can someone guide me (total JS newbie) on this presumably pretty easy task? I have a "parent" page with some text inputs in it (a form). This is what I am after: -when the user clicks a link it pops open a new window via JS - "child" (this is working). -in the "child" window there are also some text inputs (another form) (done). -when the user changes the value for 'testChild_textInput_4' in the child window, then I want it to automatically set this same value, to effectively overwrite, what is currently in 'testParent_textInput_2' in the parent window. Presumably this involves an onChange event, but it is also OK with me if the needful (the text input's value in the parent window being overwritten) happens upon the child window's form submit. If anyone can show me either trick, I would be thrilled! I set up a test page to make this all easy to talk about: http://www.yellow-turtle.com/testDumpMe_parent.html Please let me know! Thanks! -John I am working on a page where the user will select a location from a dynamically generated dropdown list. I was able to create the php multidimensional array (tested and working) from a MySql database using the users information at login, but I'm having problems converting it to a javascript multidimensional array. I need to be able to access variables that I can pass to a number of text fields within an html form. For instance, if a user belongs to a company with multiple addresses, I need to be able to let them select the address they need to prepopulate specific text fields. php array creation: Code: if ($row_locations) { while ($row_locations = mysql_fetch_assoc($locations)) { $mail[$row_locations['comp_id']]=array('mailto'=>$row_locations['mailto'], 'madd'=>$row_locations['madd'], 'madd2'=>$row_locations['madd2'], 'mcity'=>$row_locations['mcity'], 'mstate'=>$row_locations['mstate'], 'mzip'=>$row_locations['mzip'], 'billto'=>$row_locations['billto'], 'badd'=>$row_locations['badd'], 'badd2'=>$row_locations['badd2'], 'bcity'=>$row_locations['bcity'], 'bstate'=>$row_locations['bstate'], 'bzip'=>$row_locations['bzip']); } } javascript function - this should create the array and send variables to text fields. Code: function updateAddress() { var mail = $.parseJSON(<?php print json_encode(json_encode($mail)); ?>); { if (comp_id in mail) { document.getElementById('mailto').value=mail.comp_id.mailto.value; document.getElementById('madd').value=mail.comp_id.madd.value; document.getElementById('madd2').value=mail.comp_id.madd2.value; document.getElementById('mcity').value=mail.comp_id.mcity.value; document.getElementById('mstate').value=mail.comp_id.mstate.value; document.getElementById('mzip').value=mail.comp_id.mzip.value; } else { document.getElementById('mailto').value=''; document.getElementById('madd').value=''; document.getElementById('madd2').value=''; document.getElementById('mcity').value=''; document.getElementById('mstate').value=''; document.getElementById('mzip').value=''; } } } Where is this breaking? Thanks in advance. I can't seem to figure out how to accomplish this. In my website, I would like the user to input text into a single or multiple textbox(es) and then have the contents of the textbox(es) stored to either a variable or an array. Then I would like to have that variable/array compared to other arrays. Basically, the user is searching for items in a database. The user can search for as many or as little items as they want. Then the item(s) will be compared to multiple arrays to find out if what the user wants is in the database. So for example, let's say the user is searching for recipes that have all or part of these ingredients: chicken, broccoli, lemon, honey. So, there would have been a total of 4 textboxes...one for each ingredient. These ingredients are stored to an array..lets call it ingredient(). In the database of recipes, each recipe has its own array which includes the ingredients needed to make the recipe, we'll call them tag1(), tag2(), and tag3(). Now, I want the array, ingredient(), to be compared to each of the "tag" arrays to see if any of the "tag" arrays include exactly match the ingredient() tag in part or in whole. Is this possible? Hey guys, I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array. Is it possible to do this or is this use of arrays to display the data the wrong approach? The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work. |