Select dropdown issue

Hi,

I have a recurring issues with my dropdown fields. Not sure if i’m setting them up wrong but here is the set up:

On my custom profile page, i have a field that refers to a team of their choice, which they have chosen through a select field on the sign up form. However, on the update profile page, the select dropdown always select the first value, rather than the correct one. I am not sure what is causing this.

The value (though incorrect) gets passed through fine on Memberstack when they click on the update profile button.

On the field itself: i have a ms-field=“favourite-team” and ms-data=“favourite-team”.

Thanks for any help!

1 Like

Hey Julie, try removing that ms-data="favourite-team"

That may be causing the issue. You should only need one or the other…

You can also update ms-field=“favourite-team” to…

data-ms-member="favourite-team"

We created a new set of attributes that are less fragile and more flexible :+1:

Hi Duncan,

Thanks for getting back to me on this. I have tried to make the change, however this did not solve the issue. Please see below for a screen recording

1 Like

Hey Julie, thanks for the video :pray:

How are you populating that select field?

Are all the teams listed in Webflow, or do they get added to the select field after the page loads?

Hey Duncan,

They get added through custom code. Here is the script i use:

<script> // team picker // 
function addTeams(whereto) {
  var teamsfile = "Aberdeen, Admira, AEK, AEK Larnaca, AIK, Ajax, Aktobe, Alashkert, Anderlecht, APOEL, Apollon, Arouca, Arsenal, Astana, Astra, Athletic, Atlantas, Atlético, Austria Wien, AZ, B36, Bala, Balzan, Banants, Barcelona, Basel, BATE, Bayern, Beitar Jerusalem, Benfica, Beroe, Beşiktaş, Birkirkara, Bokelj, Braga, Breidablik, Brøndby, Budućnost Podgorica, Celta, Celtic, Chelsea, Chikhura, Cliftonville, Club Brugge, Connah’s Quay, Cork, Cracovia, Crusaders, Crvena Zvezda, CSKA Moskva, CSMS laşi, Čukarički, Dacia, Debrecen, Differdange, Dila, Dinamo Minsk, Dinamo Tbilisi, Dinamo Zagreb, Domžale, Dortmund, Dudelange, Dundalk, Dynamo Kyiv, Europa, FC Santa Coloma, FCI, Fenerbahçe, Ferencváros, Feyenoord, FH, Fiorentina, Flora, Fola, Folgore, Gabala, Genk, Gent, Giannina, Glenavon, Gorica, Göteborg, Grasshoppers, H. Beer-Sheva, Häcken, Hajduk Split, HB, Hearts, Heracles, Hertha, Hibernian, Hibernians, HJK, Internazionale, İstanbul Başakşehir, Jelgava, Jeunesse Esch, Juventus, Kairat, Kalju, Käpäz, København, Konyaspor, KR, Krasnodar, Kukës, La Fiorita, Legia, Leicester, Levadia, Leverkusen, Levski, Liberec, Liepāja, Liverpool, Llandudno, Lokomotiva Zagreb, LOSC, Ludogrets, Lusitans, Luzern, Lyon, M. Haifa, M. Tel-Aviv, Mainz, Man. City, Man. United, Maribor, Mariehamn, Midtjylland, Mladá Boleslav, Mladost Podgorica, Monaco, Mönchengladbach, MTK, Napoli, Neftçi, Nice, Norrköping, NSÍ, Odd, Olexandriya, Olimpija Ljubljana, Olympiacos, Omonia, Ordabasy, Osmanlıspor, Panathinaikos, Pandurii, PAOK, Paris, Partizan, Partizani, Piast, Plzeň, Porto, PSV, Pyunik, Qarabağ, Rabotnicki, Radnik, Rapid Wien, Real Madrid, Rijeka, Rio Ave, Roma, RoPS, Rosenborg, Rostov, Rudar Pljevlja, Salzburg, Samtredia, Sassuolo, Schalke, Sevilla, Shakhtar Donetsk, Shakhtyor, Shamrock Rovers, Sheriff, Shirak, Shkëndija, Sileks, Široki Brijeg, SJK, Slavia Praha, Slavia Sofia, Sloboda, Slovan Bratislava, SønderjyskE, Southampton, Sparta Praha, Spartak Moskva, Spartak Myjava, Spartak Trnava, Spartaks Jūrmala, Sporting CP, St Patrick’s, Stabæk, Standard Liège, Steaua, St-Étienne, Strømsgodset, Sūduva, Teuta, TNS, Torpedo Zhodino, Tottenham, Trakai, Tre Penne, Trenčín, UE Santa Coloma, Vaduz, Valletta, Valur, Vardar, Ventspils, Videoton, Viitorul, Vikingur, Villarreal, Vojvodina, Vorskla, West Ham, Young Boys, Zagłębie, Žalgiris, Zaria Balti, Zenit, Zimbru, Zorya, Zrinjski, Zürich, Not listed here / no favourite team";
  var teams = teamsfile.split(", ");
  for(var c = 0; c<teams.length; c++) {
    $(whereto).append('<option value="' + teams[c] + '">' + teams[c] + '</option>');
  }
}

Webflow.push(function() {
  addTeams('#Favourite-Team');
});

$("#Favourite-Team").each(function(){
 	  $(this).children().first().attr("disabled","disabled");
  });
</script>
1 Like

Why the custom code? That’s probably causing the issue. Why not just create the team list items using the settings panel of the dropdown box?

1 Like

Hey Julie, I’m afraid the code’s the issue :thinking:

Memberstack is doing its thing, then that code is replacing what Memberstack did.

@alankemsley I’m guessing she can’t add everything to Webflow because there are a TON of teams. It would take a hot minute.

Julie, any chance you could find a snippet of code that already has all of the teams in it? If not, you might try finding someone on Fiverr you can convert the above code into a select field.

Hey Duncan,

I have tried using a HTML Embed block, however it exceeds the character limit allowed by webflow.

Would you know of any way for the script to run before Memberstack does its thing?

1 Like

Thanks for giving it a try :disappointed: I didn’t think about that character limit.

Hmmm… Its times like this where I wish I knew a bit of JS.

Idea! Where did you place that script? I would try placing it in a custom code embed immediately after the select field. Maybe that will give it time to work before Memberstack has a chance to run :crossed_fingers:

Hey Duncan, after loads of trial and errors i’ve found a solution and thought i would share it here in case anyone has the same issue :slight_smile:

So the issue was that Memberstack was doing its thing before I had a chance to add the teams.

To counter that I removed the ms-data on the field, and replaced it with ms-field, so the information still get passed to Memberstack with the form. Then, I added my script within the MemberStack.onReady.then(function(member)) function, and then followed it by a call to Memberstack to get the data, and add it as a value within the select field.

Here is the code I ended up with:

MemberStack.onReady.then(function(member) {
  	
	//Add teams//  
	function addTeams(whereto) {
  		var teamsfile = "Aberdeen, Admira, AEK, AEK Larnaca, AIK, Ajax, Aktobe, Alashkert, Anderlecht, APOEL, Apollon, Arouca, Arsenal, Astana, Astra, Athletic, Atlantas, Atlético, Austria Wien, AZ, B36, Bala, Balzan, Banants, Barcelona, Basel, BATE, Bayern, Beitar Jerusalem, Benfica, Beroe, Beşiktaş, Birkirkara, Bokelj, Braga, Breidablik, Brøndby, Budućnost Podgorica, Celta, Celtic, Chelsea, Chikhura, Cliftonville, Club Brugge, Connah’s Quay, Cork, Cracovia, Crusaders, Crvena Zvezda, CSKA Moskva, CSMS laşi, Čukarički, Dacia, Debrecen, Differdange, Dila, Dinamo Minsk, Dinamo Tbilisi, Dinamo Zagreb, Domžale, Dortmund, Dudelange, Dundalk, Dynamo Kyiv, Europa, FC Santa Coloma, FCI, Fenerbahçe, Ferencváros, Feyenoord, FH, Fiorentina, Flora, Fola, Folgore, Gabala, Genk, Gent, Giannina, Glenavon, Gorica, Göteborg, Grasshoppers, H. Beer-Sheva, Häcken, Hajduk Split, HB, Hearts, Heracles, Hertha, Hibernian, Hibernians, HJK, Internazionale, İstanbul Başakşehir, Jelgava, Jeunesse Esch, Juventus, Kairat, Kalju, Käpäz, København, Konyaspor, KR, Krasnodar, Kukës, La Fiorita, Legia, Leicester, Levadia, Leverkusen, Levski, Liberec, Liepāja, Liverpool, Llandudno, Lokomotiva Zagreb, LOSC, Ludogrets, Lusitans, Luzern, Lyon, M. Haifa, M. Tel-Aviv, Mainz, Man. City, Man. United, Maribor, Mariehamn, Midtjylland, Mladá Boleslav, Mladost Podgorica, Monaco, Mönchengladbach, MTK, Napoli, Neftçi, Nice, Norrköping, NSÍ, Odd, Olexandriya, Olimpija Ljubljana, Olympiacos, Omonia, Ordabasy, Osmanlıspor, Panathinaikos, Pandurii, PAOK, Paris, Partizan, Partizani, Piast, Plzeň, Porto, PSV, Pyunik, Qarabağ, Rabotnicki, Radnik, Rapid Wien, Real Madrid, Rijeka, Rio Ave, Roma, RoPS, Rosenborg, Rostov, Rudar Pljevlja, Salzburg, Samtredia, Sassuolo, Schalke, Sevilla, Shakhtar Donetsk, Shakhtyor, Shamrock Rovers, Sheriff, Shirak, Shkëndija, Sileks, Široki Brijeg, SJK, Slavia Praha, Slavia Sofia, Sloboda, Slovan Bratislava, SønderjyskE, Southampton, Sparta Praha, Spartak Moskva, Spartak Myjava, Spartak Trnava, Spartaks Jūrmala, Sporting CP, St Patrick’s, Stabæk, Standard Liège, Steaua, St-Étienne, Strømsgodset, Sūduva, Teuta, TNS, Torpedo Zhodino, Tottenham, Trakai, Tre Penne, Trenčín, UE Santa Coloma, Vaduz, Valletta, Valur, Vardar, Ventspils, Videoton, Viitorul, Vikingur, Villarreal, Vojvodina, Vorskla, West Ham, Young Boys, Zagłębie, Žalgiris, Zaria Balti, Zenit, Zimbru, Zorya, Zrinjski, Zürich, Not listed here / no favourite team";
  		var teams = teamsfile.split(", ");
  		for(var c = 0; c<teams.length; c++) {
    	$(whereto).append('<option value="' + teams[c] + '">' + teams[c] + '</option>');
  		}
	}

	addTeams('#favTeam');

	$("#favTeam").each(function(){
 	  $(this).children().first().attr("disabled","disabled");
  	});
	//END add teams//

	
	//Link fields
  	var favTeam = member["favourite-team"];
    document.getElementById("favTeam").value = favTeam;
  })
</script>

Seems to be working well for me :slight_smile:

1 Like