drop down box elements - dynamic generation
hello all,
I could not find similar problem by searching in the forum Could you please help me with this ? I have a html page. Only when the user clicks on the drop - down box, the list should be populated - something like dynamic drop down box elements generation. I am trying to accomplish this with perl + CGI Instead of using a html page, I can make use of a perl CGI script directly to populate the values on the run, but I would like to do something like first to start with a html page, from there when there is onClick action on the drop down box, a perl script should be triggered and then a new html page to be rendered with values in the drop down box. Could you please provide some pointers for that ? Thanks |
If you have a server based script, you have to submit a form with some information, build the list on the server, and send it back to your client. You can not do it without re-loading the page and telling the server something on which it can decide how to build the list.
Alternatively you could build the list client-based usung javascript. Some good tools here jlinkels |
yes thats a server based script
Can I bind some action on the click of a drop down box ? In a form, an action is explicitly binded to a submit button, can I do something similar to that ? If I could do that, once the click action is sensed, dynamic list can be generated with a script and then the page reloaded |
Or is it possible to do it this way ?
When a html page gets loaded, is it possible to execute some script in background so that drop down list can be dynamically generated without the user having to click the drop down list and then generate ? Am not sure whether this is possible or not. Thanks much in advance |
Ajax technology can be used to do this. I've used to communicate with server-side Java-servlet, also know that .php can be used in server-side code. But no so sure about cgi-perl.
On HTML page's <body onLoad="someJavascriptMethod()"> is called. In that Javascript method, call the server-side script. Server-script returns the elements of dropdown-box as string. Like, in java, String s = "<option value='a'>a</option>" + "<option value='b'>b</option>" and returns this String. When Ajax call return from server-side script, an user-implemented callback method is invoked and in that method, dynamically update the HTML page. Here's a link to Servlet implementation; Link1 |
thanks for the reply.
I don't know much about these technologies. I had heard of them only conceptually. This is what I had tried. Instead of rendering a html page, I triggered cgi script to do that something like the below using cgi script to do that Code:
http://url/output.cgi Code:
http://url/some.html this gives me another potential problem Example: cgi script generates the html file and displays ( output.cgi ) the form in the html page is something like Code:
<form action="output.cgi" method="POST"> since the same cgi script is called which is output.cgi I have the statement in output.cgi something like Code:
use CGI; Selection values are gone. Could you please provide some pointers to overcome this ? Thank you very much |
Quote:
Code:
onclick="this.form.submit()" I have built some rather large webpages based on this technology, but I have to warn you, those were for an Intranet application. If you do this for an Internet application waiting times may become tedious for the user. AJAX could also be an option, a very nice implementation indeed without page refreshes, but you have to rely heavily on JavaScript and DOM, and the user would have to suffer response times as well if the connection is below a few mbit. Last but not least, I have no experience with cgi and I don't know how powerful it is. But in PHP it is fairly easy to create select boxes on the server site, handle form input from posted data etc. Sorry that I cannot reply to your latest post in detail, I do not completely understand what you tried to explain, but that is my fault. jlinkels jlinkels |
All times are GMT -5. The time now is 10:34 AM. |