1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Rep Power
    I have following code. Its ok if i have only one City name and prov. name. Now i have changed that user can put in multiple City and state names. so every time txtMktCityName and txtMktPhyStateProv are changing to txtMktCityName0 and xtMktPhyStateProv0 and so on depending on the user how many values are being entered. so i was wondering how to write Java script so that code also changes dynamically as txt names are changed.

    <SCRIPT Language="JavaScript">
    function checkCityName(mthis)
    { if(mthis.txtMktCityName.value=="")
    alert("Please Enter the Marketing City Name");
    return false;
    alert("Please Enter the Mkt State Prov Name");
    return false;
    return true;

  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Rep Power


    I really don't know what you're meaning, but if it is to dynamically refer to formfields this is a way to do it:


    function yeah( iElement ) {

    alert("Value=" + document.frmYeah.elements["txtYeah" + iElement].value);

    <body bgcolor="#ffffff" text="#000000" id=all>

    <form name="frmYeah">
    <input onBlur="yeah(1)" name="txtYeah1"><br>
    <input onBlur="yeah(2)" name="txtYeah2"><br>
    <input type="submit" name="btn">


    Here you can see that I use the 'elements' array with a composit string to refer to the element name ("txtYeah" + "1" e.g.)

Similar Threads

  1. Replies: 0
    Last Post: January 6th, 2004, 02:05 PM
  2. External JavaScript file problem
    By FTK2003 in forum JavaScript Development
    Replies: 11
    Last Post: September 13th, 2003, 11:21 AM
  3. External JavaScript file from within a JavaScript function?
    By DKDiveDude in forum JavaScript Development
    Replies: 10
    Last Post: August 19th, 2003, 03:24 AM
  4. delimiting javascript
    By scream in forum JavaScript Development
    Replies: 3
    Last Post: August 15th, 2003, 04:03 PM
  5. getting javascript error when using PHP and javascript
    By Dalamar in forum JavaScript Development
    Replies: 8
    Last Post: December 17th, 2001, 07:41 AM

IMN logo majestic logo threadwatch logo seochat tools logo