Results 1 to 5 of 5
  1. #1
    JavaJimme is offline Member
    Join Date
    Nov 2012
    Posts
    30
    Rep Power
    0

    Default change attribute names client-side

    Hey, I have set alot of different attributes to make different google markers in javascript.
    I want the forloop EL expression "${title0}" to become "${titlex}" so everytime the loop loops, title0 changes to title1, title2 title3.
    "${title"x"}", "${titlex}" or "${title+'1'}" doesn't work obviously.. Tried to google and couldn't find anything usefull..

    Client-side
    Java Code:
    	for (var x =0; x< "${size}"; x++){
    
    
           //the code between this needs to change
    		makeMarker("${title0}", "${lat0}", "${lng0}","${contentstring0}");
           //
    
    	}
    
    	
    	function makeMarker(title, lat, lng, contentstring){
    		
    		var point = new google.maps.LatLng(lat,lng);
    		var marker = new google.maps.Marker({
    			position:point,
    			map:firstmap,
    			title:title,
    			draggable:true,
    		})
    		var infowindow = new google.maps.InfoWindow({
    			content:contentstring
    		
    		})
    		
    		google.maps.event.addListener(marker, 'click', function(){
    			infowindow.open(firstmap, marker);
    		});
    	};
    Thanks in advance

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: change attribute names client-side

    I don't get it. If you want ${title0}, ${title1}, ${title2}, that would imply there is some variables on the Java side with those names. I think what you want to achieve is to output a STRING "title" followed by a counter number.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    JavaJimme is offline Member
    Join Date
    Nov 2012
    Posts
    30
    Rep Power
    0

    Default Re: change attribute names client-side

    Thanks for reply,

    But what I want to achieve is the title attributes to change with the forloop.

    For example the attribute of "${title0}" is: Eagle
    The attribute of "${title1}" is: Pigeon
    The attribute of "${title2}" is: Penguin

  4. #4
    JavaJimme is offline Member
    Join Date
    Nov 2012
    Posts
    30
    Rep Power
    0

    Default Re: change attribute names client-side

    nevermind I got a solution, not the best way to code but.. It's just for school.

    Java Code:
    var titles = "${title}".split(",");
    	var lat = "${lat}".split(",");
    	var lng = "${lng}".split(",");
    	var contentString = "${contentString}".split(",");
    	
    	for (var x =0; x< "${size}"; x++){
    		makeMarker(titles[x], lat[x], lng[x], contentString[x]);
    	}

  5. #5
    ErnestNamp is offline Member
    Join Date
    Feb 2014
    Location
    Posts
    1
    Rep Power
    0

    Default Эротические и

    Однажды я случайно наткнулся на один очень интересный сайт. Хотите и Вам покажу? Вот:
    картинки порно. Очень хорошо, что есть такие сайты.

Similar Threads

  1. Replies: 0
    Last Post: 10-06-2013, 03:30 PM
  2. Client-side or server-side XML parsing?
    By noodle_variation_187-X in forum JavaServer Pages (JSP) and JSTL
    Replies: 11
    Last Post: 05-31-2012, 09:06 AM
  3. New to client-side servers
    By Bestsanchez in forum New To Java
    Replies: 2
    Last Post: 02-04-2012, 11:31 PM
  4. Replies: 1
    Last Post: 03-20-2010, 07:03 PM
  5. Need to change cursor to hourglass at server side
    By bgupta in forum Java Servlet
    Replies: 0
    Last Post: 02-16-2009, 07:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •