Jump to content
php.lv forumi

Divas atsevišķas finkcijas vajag vienā


Sasa

Recommended Posts

#1

<script type="text/javascript">
//pievieno db kodu un koda bildes url
function izvadisana() {
var cn_1 = new ActiveXObject("ADODB.Connection");
var strConn_1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =\\\\192.168.0.150\\tmp\\webk\\Katalogs.mdb;Persist Security Info=False";
cn_1.Open(strConn_1);
var rs_1 = new ActiveXObject("ADODB.Recordset");
elementCount_kods = document.all("Kods").length;
for (i=0; i<elementCount_kods; i++) { 
var file_name = document.all('z',i).value.split('\\');
var SQL_1 = "INSERT INTO bilzu_kodi (kods, bildes_url) VALUES ('"+ document.all('Kods',i).value +"', '"+"http://192.168.0.164/uploadasp/img/"+ file_name[3] +"')";
rs_1.Open(SQL_1, cn_1);

//alert(document.all('Kods',i).value +" "+"http://192.168.0.164/uploadasp/img/"+ file_name[3]);
}
rs_1.Close();
cn_1.Close();
}
</script>

#2

<script language=VBScript event=OnClick for=Button1>
<!--

Set conn = CreateObject("ADODB.Connection")
' Connect to the database
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\192.168.0.150\tmp\webk\Katalogs.mdb"
conn.Open strConnect

'papildinat izstradajumu arhivu
SQL_papildinat_izstradajumus = "INSERT INTO Izsradajumi ( Kods ) SELECT pievienojamie_izstradajumi.Kods FROM pievienojamie_izstradajumi;"
Set rs = conn.Execute(SQL_papildinat_izstradajumus)

'pievienoto kodu ar urbumiem pievienot urbumu tabulai
SQL_urbumu_tbl = "INSERT INTO tbl_urbumi ( Kods, Urbumi )SELECT pievienojamie_izstradajumi.Kods, pievienojamie_izstradajumi.Urbumi FROM pievienojamie_izstradajumi;"
Set rs_urbumi = conn.Execute(SQL_urbumu_tbl)

call window.history.back(1) 'explorera back poga
-->
</SCRIPT>

, kā lai šīs abas funkcijas paliek zem kādas no šīm pogām:

pirmā poga.

<INPUT id=Button1 onmouseover=mouseOver_save() style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; Z-INDEX: 1; BORDER-LEFT: 1px solid; WIDTH: 3.407cm; BORDER-BOTTOM: 1px solid; HEIGHT: 0.527cm" type=button value="Pievienot arhīvam">

otrā poga.

   <input id=btn_upload type=submit value="Upload" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; Z-INDEX: 1; BORDER-LEFT: 1px solid; WIDTH: 3.407cm; BORDER-BOTTOM: 1px solid; HEIGHT: 0.527cm" onclick="izvadisana();">

 

EDIT:

no otrās finkcijas SQL'u pievienoju pirmajai :) un tagad izskatās ka strādā

<script type="text/javascript">
//pievieno db kodu un koda bildes url
function izvadisana() {
var cn_1 = new ActiveXObject("ADODB.Connection");
var strConn_1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =\\\\192.168.0.150\\tmp\\webk\\Katalogs.mdb;Persist Security Info=False";
cn_1.Open(strConn_1);
var rs_1 = new ActiveXObject("ADODB.Recordset");
var sql_2 = "INSERT INTO Izsradajumi ( Kods ) SELECT pievienojamie_izstradajumi.Kods FROM pievienojamie_izstradajumi;";
rs_1.Open(sql_2,cn_1);
var sql_3 = "INSERT INTO tbl_urbumi ( Kods, Urbumi )SELECT pievienojamie_izstradajumi.Kods, pievienojamie_izstradajumi.Urbumi FROM pievienojamie_izstradajumi;";
rs_1.Open(sql_3,cn_1);
elementCount_kods = document.all("Kods").length;
for (i=0; i<elementCount_kods; i++) { 
var file_name = document.all('z',i).value.split('\\');
var SQL_1 = "INSERT INTO bilzu_kodi (kods, bildes_url) VALUES ('"+ document.all('Kods',i).value +"', '"+"http://192.168.0.164/uploadasp/img/"+ file_name[3] +"')";
rs_1.Open(SQL_1, cn_1);	
//alert(document.all('Kods',i).value +" "+"http://192.168.0.164/uploadasp/img/"+ file_name[3]);
}
rs_1.Close();
cn_1.Close();
}
</script>

Edited by Sasa
Link to comment
Share on other sites

Kāpēc tu vispār tur miksē savu kodu ar VBScript ar JavaScript valodām? Paņem vienu un raksti visu vienā valodā.

Un ja tev ir divas funkcijas A un B, tad var mierīgi uztaisīt funkciju C, kas izsauc esošās fjas:

function C()
{
A();
B();
}

Link to comment
Share on other sites

×
×
  • Create New...