Skip to main content
Participating Frequently
September 25, 2019
Answered

DROPDOWN

  • September 25, 2019
  • 1 reply
  • 1793 views

The problem is  when I try to  editing one of my values all the drop-down lists return  to the first one in the list and not the one they selected originally.

Thats why the user have to chose original value in drop-down lists everytime  When they editing. .

this is my code :

<cfset AboneID="">
<cfset Aciklama="">
<cfset musteriTipi="">
<cfif IsDefined("url.id") and IsNumeric(url.id)>
<cfquery name="u" datasource="deneme">
SELECT * from MusteriHareketleri
where MusteriId=<cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
</cfquery>
<cfset AboneID = u.AboneID>
<cfelseif IsDefined("url.did") and IsNumeric(url.did)>
<cfquery datasource="deneme">
DELETE MusteriHareketleri WHERE MusteriId=<cfqueryparam cfsqltype="cf_sql_integer" value="#url.did#">
</cfquery>
</cfif>
<form name="add_deneme" method="post">
<table border="3">
<tr>
<td><strong>Abone ID: </strong></td>
<td><input type="text" name="AboneID" id="a" required="yes" value="<cfoutput>#AboneID#</cfoutput>" >
</td>
</tr>
<br>
<tr>
<td><strong>Musteri Hareket Kodu: </strong></td>
<td>
<select name="Aciklama" required="yes" >
<option value="YENI ABONELIK KAYDI">1</option>
<option value="HAT DURUM DEGISIKLIGI">2</option>
<option value="SIM KART DEGISIKLIGI">3</option>
<option value="ODEME TIPI DEGISIKLIGI">4</option>
<option value="ADRES DEGISIKLIGI">5</option>
<option value="IMSI DEGISIKLIGI">6</option>
<option value="TARIFE DEGISIKLIGI">7</option>
<option value="DEVIR (MUSTERI) DEGISIKLIGI">8</option>
<option value="NUMARA DEGISIKLIGI">9</option>
<option value="HAT IPTAL">10</option>
<option value="MUSTERI BILGI DEGISIKLIGI">11</option>
<option value="NUMARA TASIMA">12</option>
<option value="NUMARA DEGISMEDEN NAKIL">13</option>
<option value="NUMARA DEGISTIREREK NAKIL">14</option>
<option value="IP DEGISIKLIGI">15</option>
</select>
</td>
</tr>
<br>

<tr>
<td><strong>Musteri Tipi: </strong></td>
<td>
<select name="musteriTipi" required="yes" >
<option value="G-SAHIS">G-SAHIS</option>
<option value="G-SIRKET">G-SIRKET</option>
<option value="T-SIRKET">T-SIRKET</option>
<option value="T-KAMU">T-KAMU</option>

</select>
</td>
</tr>
</table>
<br><input type="submit" name="Kaydet" value="KAYDET">
<cfif IsDefined("url.id") and IsNumeric(url.id)>
<input type="hidden" name="MusteriId" value="<cfoutput>#url.id#</cfoutput>">
</cfif>
</form>
<cfif IsDefined("form.MusteriId")>
<cfquery datasource="DENEME">
UPDATE MusteriHareketleri
SET
AboneID=<cfqueryparam cfsqltype="cf_sql_integer" value="#form.AboneID#">,
Aciklama=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Aciklama#">,
musteriTipi=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.musteriTipi#">

WHERE MusteriId= <cfqueryparam cfsqltype="cf_sql_integer" value="#form.MusteriId#">
</cfquery>

<cfelseif IsDefined("form.Aciklama")and isdefined("form.musteriTipi")>
<cfquery datasource="DENEME">

INSERT INTO MusteriHareketleri (AboneID,Aciklama,musteriTipi)
values (
<cfqueryparam cfsqltype="cf_sql_integer" value="#form.AboneID#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Aciklama#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.musteriTipi#">
)
</cfquery>
<cflocation url="http://127.0.0.1:8500/ADD_DENEME.cfm" addtoken="false">
</cfif>
<cfquery name="ADD" datasource="DENEME">
select * from MusteriHareketleri ;
</cfquery>
<cftable query="add" colheaders="True">
<cfcol header="MusteriId" text="#MusteriId#">
<cfcol header="Aciklama" text="#Aciklama#">
<cfcol header="musteriTipi" text="#musteriTipi#">
<cfcol header="AboneID" text="#AboneID#">
<cfcol header="zamani" text="#zamani#">
<cfcol header="Durum" text="<a href='http://127.0.0.1:8500/ADD_DENEME.cfm?id=#add.MusteriId#'>Edit</a>">
<cfcol header="" text="<a href='http://127.0.0.1:8500/ADD_DENEME.cfm?did=#add.MusteriId#'>DELETE</a>">
</cftable>

    This topic has been closed for replies.
    Correct answer mykaf73934846

    You can have a variable, but your <option> tags above don't include any variables or "selected" attributes. If your options are in a query or some other loop, you can include your "selected" attribute there. Here's how I like to do it:

    <cfloop query="myQuery">
    <cfset selected = (myQuery.myColumn eq previouslySelectedValue) ? "selected" : "">
    <option value="#myQuery.myColumn#" #selected#>#myQuery.myColumn#</option>
    </cfloop>

    PS...Dear Adobe, why isn't Coldfusion included in the list of languages in the Code editor?

    1 reply

    Inspiring
    September 27, 2019

    You don't appear to be setting any of your select options as selected. By default the first option is always selected; if you don't want the default, you must mark a particular option as selected.

    ressifeltAuthor
    Participating Frequently
    September 30, 2019
    I want "selected" to be a variable. When I select something, next time i m try to editing i wanna see the selected value as a default
    mykaf73934846Correct answer
    Inspiring
    October 24, 2019

    You can have a variable, but your <option> tags above don't include any variables or "selected" attributes. If your options are in a query or some other loop, you can include your "selected" attribute there. Here's how I like to do it:

    <cfloop query="myQuery">
    <cfset selected = (myQuery.myColumn eq previouslySelectedValue) ? "selected" : "">
    <option value="#myQuery.myColumn#" #selected#>#myQuery.myColumn#</option>
    </cfloop>

    PS...Dear Adobe, why isn't Coldfusion included in the list of languages in the Code editor?