JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 2nd, 2001, 12:56 PM
fatehjeetsandhu fatehjeetsandhu is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Va,USA
Posts: 2 fatehjeetsandhu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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;
}
if(mthis.txtCountryCode.value=="1")
{
if(mthis.txtMktPhyStateProv.value=="")
{
alert("Please Enter the Mkt State Prov Name");
return false;
}
}
return true;
}
</SCRIPT>

Thanks

Reply With Quote
  #2  
Old January 16th, 2001, 09:02 AM
twista twista is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 23 twista User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

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:

<html>
<script>

function yeah( iElement ) {

alert("Value=" + document.frmYeah.elements["txtYeah" + iElement].value);
document.frmYeah.btn.focus();
}
</script>

<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">
</form>

</body>
</html>


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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Dyanamic Javascript alerts

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap