Announcement

Collapse
No announcement yet.

anyone used an image as global variable??

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • anyone used an image as global variable??

    hi guys, i have one HTML image field in grid, with link, it works fine

    the image itself is small png icon, i want to display different png icon when specific field has different value

    what I done is: I took the link that is displayed in the image path field and added it to OnScriptInt

    Code:
    [glo_image]="sys__NM__ico__NM__lib__NM__047.png";
    and added [glo_image] instead of the image path field, but didn't work...

    i was thinking to make this [glo_image] like if {field}==1 then [glo_image]="image_path" and if {field}==2 then [glo_image]=different image path

    anyone has done similar thing? am i missing something? wrong path? doesn't work this way?

  • #2
    Originally posted by MikeDE View Post
    hi guys, i have one HTML image field in grid, with link, it works fine

    the image itself is small png icon, i want to display different png icon when specific field has different value

    what I done is: I took the link that is displayed in the image path field and added it to OnScriptInt

    Code:
    [glo_image]="sys__NM__ico__NM__lib__NM__047.png";
    and added [glo_image] instead of the image path field, but didn't work...

    i was thinking to make this [glo_image] like if {field}==1 then [glo_image]="image_path" and if {field}==2 then [glo_image]=different image path

    anyone has done similar thing? am i missing something? wrong path? doesn't work this way?
    Hey Mike

    I have used an image as a global var before without a problem, but u do need to include the file path of the image. so u should be able to use what you were thinking {field}==1 (file_path_1) and {field}==2 (file_path_2) and add that to the image global var.
    so like so: [glo_image]={file_path_and_file_name}; previously combining the two of course.

    hope that helps

    Comment


    • #3
      Hi Jamie

      yes that is what I want, but i couldn't find the correct file path, i tried as mentioned above, to put the file name as it is supposed to be in the image field, and also tried like ../lib/img...imagename.png but also image didn't show up if you have exact code othe glo_image global variable would appreciate it Jamie

      Comment


      • #4
        If you want to use the image in the same grid why don't you just use it in the onrecord event where you can check the value of any field and use the image you want on any other field?
        Doing everything in the same event you dont need global variables.

        Comment


        • #5
          okay, but how to add it there as html image field? there is no label field in grid! also you are right, but html image gives the flexibility to link to other applications with global variables as parameters, do you think we can still link to applications with variables if it is "some field" onRecord event? please advise

          Comment


          • #6
            The field that will show the image can be a plain text field created in SC ("field_showing_image" in my example below).
            then something like this should work:

            Code:
            $imagepath="/your_image_path/"; <-- usually /scriptcase/app/[appname]/_lib/img/
            switch {field_to_check}
            	case value1:
            	  $image = "image_for_value1.png";
            	break;
            	case value2:
            	 .... etc.
            }
            
            {field_showing_image} =  '<img border="0" src="' $imagepath . $image . '">';
            sc_link(field_showing_image, app, parameters.... ); <-- see sc_link macro doc
            (check the syntax, I wrote it in the forum so there will be errors\typos for sure)

            I usually simplify by naming my image files according to the value of the field I check
            So that you don't need any IF or SWITCH in your PHP code and you can just set the image as :

            $image = "image_for_value" . {field_to_check} . ".png";

            But it's not always feasible.
            Last edited by robydago; 02-09-2015, 08:22 AM.

            Comment


            • #7
              hi roby and thanks a lot

              seems so good so far, text field can be used to display image in grid onRecord as you described, but couldn't manage to have the parameters work

              I wanna "move" like 5 fields from the grid onRecord to the singleForm application, I tried all what I saw in help and examples but didn't work, still the singleForm opens like doesn't recieve any global variable..., getting nuts again

              here is the code grid > on Record (image displays ok, link working, but like without paramaters at all!)

              Code:
              if ({mystatus}=='1') {
              {gonewep} = "<img src='../_lib/img/sys__NM__ico__myimage12.png' width='25px' height='25px'>";
              sc_link({gonewep}, formnewep.php, 
              {id}=[toform_id];
              {name}=[toform_name];
              {class}=[toform_class];
              {devi}=[toform_devi];
              {tel}=[toform_tel];
              {mob}=[toform_mob];
              {ptpic}=[toform_pic]
              
              )
              }	
              	
              if ({mystatus}=='2') {
              {gonewep} = "<img src='../_lib/img/sys__NM__ico__myimage13.png' width='25px' height='25px'>";
              
              }
              any quick thoughts how to pass those fields as global variables to form successfully?

              Comment


              • #8
                update:

                never mind, got it working finally this way

                Code:
                toform_id={id};
                toform_name={name};
                toform_class={class};
                
                etc...
                Thanks a lot

                Comment

                Working...
                X