Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-30-2007, 08:42 PM   PM User | #1
terp_in_umcp
New Coder

 
Join Date: Jan 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
terp_in_umcp is an unknown quantity at this point
ASP in Javascript

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????
terp_in_umcp is offline   Reply With Quote
Old 01-31-2007, 11:48 AM   PM User | #2
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
You need to look into use Ajax and not just javascript.
degsy is offline   Reply With Quote
Old 02-01-2007, 05:32 PM   PM User | #3
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Code:
<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>
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:53 AM.


Advertisement
Log in to turn off these ads.