...

View Full Version : ASP in Javascript



terp_in_umcp
01-30-2007, 09:42 PM
Hi there...I am trying to create a input form field with a value say " American Express". When user clicks on this field to edit it, it turns into a dropdown menu which is pulling all credit cards names from a database table....so users can choose an option from the menu....

1) Is is too much hassle to achieve...I thought it might be kinda neat.

2) Here's the code:

<form name="CreditCardform" method="post" action="anaspppage.asp", target="main">

<td><input name=CardType onclick="ShowDropDown();" Value="<%=CreditCardDetail("Description")%>"></td>

</form>

========================================================

<script language="JavaScript1.2"><!--
function ShowDropDown()
{
<% mySQL = "SELECT * FROM CreditCardTypes order by code"
Set CreditCardTypes= Con.Execute( mySQL )

%>

<td class=tabletd><select name=CardType class=fields>

<option></option>
<% do while CreditCardTypes.eof<>true %>

<option <% if request("CardType")=CreditCardTypes("Description") then %>selected<% end if %> value='<%=CreditCardTypes("Code")%>'><%=CreditCardTypes("Description")%></option>

<% CreditCardTypes.movenext
loop

CreditCardTypes.close
set CreditCardTypes=Nothing%>

<% end if %>

</td>

}
// --></script>


=======================================================

The javascript is completely wrong coz I just copied it from the existing form but thats the idea of what a want to try...a drop down..maybe i should use document.Page.homephone.value=document.CreditCardform.CardType.value= something.....any clues????

degsy
01-31-2007, 12:48 PM
You need to look into use Ajax and not just javascript.

glenngv
02-01-2007, 06:32 PM
<script type="text/javascript">
function showDropdown(ccTxtFld){
var sel = ccTxtFld.form.ccSel;
for (var i=0; i<sel.options.length;i++){
if (sel.options[i].text == ccTxtFld.value){
sel.selectedIndex = i;
break;
}
}
sel.style.display = "inline";
ccTxtFld.style.display = "none";
sel.focus();
}

function showText(ccSelect){
var ccTxtFld = ccSelect.form.ccTxt;
ccTxtFld.value = ccSelect.options[ccSelect.selectedIndex].text;
ccTxtFld.style.display = "inline";
ccSelect.style.display = "none";
}
</script>
...
<form>
<input type="text" name="ccTxt" onfocus="showDropdown(this)" value="<%=CreditCardDetail("Description")%>" /><select name="ccSel" style="display:none;" onchange="this.blur();" onblur="showText(this)">
<option></option>
<%
mySQL = "SELECT * FROM CreditCardTypes order by code"
Set CreditCardTypes= Con.Execute( mySQL )
do while CreditCardTypes.eof<>true
%>

<option <% if request("CardType")=CreditCardTypes("Description") then %>selected<% end if %> value="<%=CreditCardTypes("Code")%>"><%=CreditCardTypes("Description")%></option>

<% CreditCardTypes.movenext
loop

CreditCardTypes.close
set CreditCardTypes=Nothing
%>

</select>
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum