• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Validation problem

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I want to write afuncion to get the text boxes dynamically if the message contains PX(index of PX).
i have written a function but i m getting a a text box if the the message doesnt contain any index of PX.

the sample code as follows..

<script>
var htmlstr='';
function populate(par) {


var param;
var count=0;
var currNode;
htmlstr='';
XMLID.async = false;
XMLID.load("getdata.jsp?rtype="+par);

objNodeList = XMLID.getElementsByTagName("MSG");
if(objNodeList.length>0){
document.f1.msg.value = objNodeList.item(0).text;
}
objNodeList = XMLID.getElementsByTagName("PARAM");
if(objNodeList.length>0){
param = objNodeList.item(0).text;
var sparam=param.split(",");
if(sparam.length>0){
var msgs=document.f1.msg.value;
var s=0;
var e=0;
for(var i=0;i<sparam.length;i++){
e=msgs.indexOf('PX'+sparam[i].toUpperCase());
htmlstr+=msgs.substring(s,e)+"<input type=text name='"+sparam[i]+"'>";
s=e+sparam[i].length+2;

}
htid.innerHTML=htmlstr;
}
}


}

<body>
<tr>
<td width="268"><b>
<font face="Verdana" color="#4D6EB0" size="2">
Shortcode</font></b></td>
<td width="181">
<select size="1" name="shortcode" onChange="return populate(this.value)" style="color: #4D6EB0; font-size: 10pt; font-family: Verdana; font-weight: bold">
<option selected value="SELECT">---Select Shortcode---
</option>
<% while(rs.next()){%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%></option>
<%}%>
</select></td>
</tr>

<div id="htid"></div>


any suggestins?
Thanks in advance
Santhosh
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sanny,

I don't see any if condition after checking indexOf "PX".

 
Sanny kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks pavan
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic