/    Sign up×
Community /Pin to ProfileBookmark

PHP Select Box image function

? Hi all, its great to have this online community, well uhm i just wonderin’ if someone could help me on this..

well i am doing a PHP based front end for the MRTG index page and i’m utilising a select box to enable the user to view any desired graph(a png file) from selection made from the given select box. by default, all type of graph will be displayed on the page. As the user select the choice from the select box, only the desired type of graph is displayed…

Well, i have googled this but not much has been found, could anybody relay me some PHP script on this dilemma??… I’m so much confused!!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehJan 14.2007 — How are you differenciating between the different graft types on the server?
Copy linkTweet thisAlerts:
@serukomuauthorJan 14.2007 — Hey thanx for the super fast reply!! ! ? well bokeh ...the graph are actually auto generated by the MRTG engine. This 'engine' is actually a Perl script that are customized by us based upon MIB-OIDs, which is a set of number that behaves as a parameter for the types of data that are available inside the device/ or network elements pulled by MRTG. So after we had customized the MRTG 'engine', once running it will auto-produced the graphs that we needeed in PNG format inside a directory of the server. [B]We deferrentiate the graphs , just by its name. ( exp : cpuload _day1.png, cpuload _day2.png)[/B], . The MIB-OID example are such as :

MIB-OID : 1.3.6.1.4.1.9.9.273.1.1.2.1.1

cDot11ActiveWirelessClients OBJECT-TYPE


SYNTAX Gauge32 (0..2007)

UNITS "Device"

MAX-ACCESS read-only

STATUS current

DESCRIPTION

"This is the number of wireless clients

currently associating with this device on this

interface."

::= { cDot11ActiveDevicesEntry 1 }

So , the task ahead for me is [B]to make an index page that display all this graph from the file directory into one page[/B]. By default the MRTG can be manipulated to make such index page, but only in very basic form, just by displaying all the available graph in the page.The index page are in HTML, so I assumed that some PHP scripts can be embedded to edit this index page and thus the need for the select box in PHP image function...So bokeh what do you think???
Copy linkTweet thisAlerts:
@bokehJan 14.2007 — You need a method of differenciation that PHP can understand. For example:

[B]type_name.png[/B]

That way PHP can read the directory and recognise the types.
Copy linkTweet thisAlerts:
@serukomuauthorJan 19.2007 — Well thanx bro ...uhmm but how about this :

<script>

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&paren... {

d=parent.frames[n.substring(p+... n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

for(i=0;!x&&d.layers&&i<d.laye... x=MM_findObj(n,d.layers[i].doc...

if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

var i,j=0,x,a=MM_swapImage.argumen... document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=MM_findObj(a[i]))!=null){d... if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

</script>



After that you must have in the value of the dropdown list the name of the image in order to use this script. And add the onchange method to the <select> tag like this :



<select name='imgpicker' onchange = "MM_swapImage('img','','path/t... + options[selectedIndex].value,1...

<option value='myimage1.gif'>myimage1....

<option value='myimage2.gif'>myimage2....

</select>



Well this is in javascript...can it be implemented in PHP...or can this be embedded in PHP??...
×

Success!

Help @serukomu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...