salmia 0 Report post Posted February 8, 2010 salam...nk mntk tlg klu ade expert2 on perl n ajax yg leh ajr cmne nk wat multiple ajax ni.klu x leh ajax onchange pn ok je... Quote Share this post Link to post Share on other sites
johnburn 6 Report post Posted February 8, 2010 apa yg cik salmia maksudkan dgn multiple ajax tu?bleh bg cnth situasi x?onchange tu bkn ajax, just event handler dlm javascript je. Quote Share this post Link to post Share on other sites
salmia 0 Report post Posted February 8, 2010 ye, mksd sy klu xleh ajax pn, onchange javascript pn xpe...ok, lupekn sal ajax..cmni, sy nk wat 3 dropdown list.list ke2 bergantung kpd id list yg 1st dan list ke3 based on list ke2.tp sume nye amik data dr database.ni kne gune perl.da wat coding tp yg jd nye 1st n 2nd list je.3rd list xkuar pape2...ade idea x???klu xclear lg plez gtau... ::fresse:: Quote Share this post Link to post Share on other sites
johnburn 6 Report post Posted February 8, 2010 lg clear kl bg script yg dh ada kotsbb yg 1st ngan 2nd dh jd, ptt sama je ngan yg 3rd pn Quote Share this post Link to post Share on other sites
salmia 0 Report post Posted February 8, 2010 $ajx_ctrl = $query->param('ajx_ctrl');$co_id = $query -> param('select_co'); my $exported_fx = sub { my $searchterm = shift; my $sql = qq< select file_name from file_name where id_module = ? >; my $dbh_label = $dbh_label; my $sth = $dbh_label->prepare( $sql ); $sth->execute( $searchterm . '%' ); my $html1 = ""; $html1 = qq!<select name="file_name" id="id_module" $input_style > #OnChange="details( ['users'],['ddiv'] ); return true;">\n!; my $firstrow = $sth->fetch(); if ( defined $firstrow ) { $html1 .= qq!<option >! .qq!- Select One -! . qq!</option>\n!; $html1.= qq!<option>! . $firstrow->[0] . qq!</option>\n!; # dot on each option from the db while ( my $row = $sth->fetch() ) { $html1.= qq!<option>! . $row->[0] . qq!</option>\n!; } } else {$html1 .= qq!<option >! .qq!- Select One -! . qq!</option>\n!;} $html1 .= qq!</select>\n!; #&common_error("$html1"); return($html1);};my $dbh_label = $dbh_label; $file_base .=qq~ <select name="file_name" $input_style> <option>- Select One -</option> </select> ~; my $exported_form = sub { my $searchterm2 = shift; my $sql2 = qq< select form_action from form where id_file = $id >; my $dbh_label = $dbh_label; my $sth2 = $dbh_label->prepare( $sql2 ); $sth2->execute( $searchterm2 . '%' ); my $html2 = ""; $html2 = qq!<select name="form_action" id="id_file" $input_style > #OnChange="details( ['users'],['ddiv'] ); return true;">\n!; my $firstrow2 = $sth2->fetch(); if ( defined $firstrow2 ) { $html2 .= qq!<option >! .qq!- Select One -! . qq!</option>\n!; $html2.= qq!<option>! . $firstrow2->[0] . qq!</option>\n!; # dot on each option from the db while ( my $row = $sth2->fetch() ) { $html2.= qq!<option>! . $row->[0] . qq!</option>\n!; } } else {$html2 .= qq!<option >! .qq!- Select One -! . qq!</option>\n!;} # close off the select and return $html2 .= qq!</select>\n!; return($html2);}; $form_base .=qq~ <select name="form_name" $input_style> <option>- Select One -</option> </select> ~; #--- get module ---# $sql = qq~ SELECT id, module FROM module ~; $sth = $dbh_label->prepare($sql); $sth->execute() or &common_error("SQL","Couldn't execute statement : $DBI::errstr",1); $sel_module .=qq~ <option value="">- Select One -</option> ~; while (($id, $module) = $sth->fetchrow_array()) { $sel_module .=qq~ <option value="$id" >$module</option> ~; } $sth->finish(); #----------------------# ### start add company form ## my $Show_Form = sub {my $html = "";$html .= <<EOT;<HTML><HEAD><title>CGI::Ajax Example</title></HEAD><BODY> <form action="setting_label_ajax.cgi" method=post name="mainform"> <input type="hidden" value="Save" name="action"> <input type="hidden" value="2" name="link"> <tr height="20"> <td bgcolor="$table_color"><div name="co_level" id="co_level"><$table_title> <b>$forwhat</b></font></div></td> </tr> <tr> <td width="729"> <div align="left"> <!-- WE REPLACE THE HIDDEN TABLE ABOVE WITH THIS NEW ONE --> <table width="100%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber21"> <tr> <td> <center> <table border="0" cellpadding="1" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber20" width="90%"> <tr height="8"><td></td></tr> <tr height="25"> <td width="22%"><$content_style>Module</font></td> <td width="2%"><$content_style>:</font></td> <td width="76%" align="left"><select name="module" id="module" OnChange="search( ['module','NO_CACHE'],['ddiv'] ); return true;" $input_style> $sel_module </select> </td> </tr> <tr height="25"> <td><$content_style>File Name</font></td> <td><$content_style>:</font></td> <td> <div id="ddiv"> <select name="file" id="file_name" OnChange="search( ['file_name','NO_CACHE'],['ddiv'] ); return true;" $input_style> $file_base </select> </div> </td> </tr> <tr height="25"> <td><$content_style>Form</font></td> <td><$content_style>:</font></td> <td> <div id="ddiv"> $form_base </select> </div> </td> </tr> <tr height="8"><td colspan="3"></td></tr> </table> </td> </tr> <tr> <td width="100%"> <p align="right"> <input type="hidden" name="type" value="$type"> <input type="button" name="back" value="Back" onClick="document.location = 'setting_label.cgi?'" $button_style> <input type="submit" name="Save" value="Save" $button_style> </td> </tr> </table> <!-- NEW TABLE ENDS HERE --> <tr><td> </td></tr> <tr> <td align="left"> <div align="left"> </div> </td> </tr> </form> </BODY></HTML>EOTreturn($html);};my $pjx = CGI::Ajax->new( search => $exported_fx, );$tmpl ="";if($ajx_ctrl eq 1){$tmpl = "GLOBAL";}else{$tmpl = "";}$ajx_ctrl =0;# not show the html, which will include the embedded javascript code# to handle the ajax interaction$content="";$pjx->JSDEBUG(0);$pjx->DEBUG(0);$content = $pjx->build_html($query,$Show_Form); # this outputs the html for the page $module = '<a href="hrms_setting.cgi"><span class="flow_link">HRMS Application Setting</span></a>'; $module_func = '<a href="setting_company.cgi"><span class="flow_link">Company Setting</span></a><span class="flow_link"> - </span><span class="flow_title">Add New Company</span>';#&common_error("$content")&output($content, $module, $module_func, $search_link, $tmpl);$forwhat = "";$file_base = "";$form_base = "";------------------------------------------sy bru je berjinak2 ngn perl ni.ajax ngn javascript pn bru nk explore.klu salah declare tu tlg tnjukkn...p/s:pertolongan anda amat dihargai Quote Share this post Link to post Share on other sites