Ir para conteúdo
Fórum Script Brasil
  • 0

Replace


Guest valmello

Pergunta

Bom dia! Estou com um sistema onde existe um campo valor com uma determinada mascara de moeda porém gostaria que fosse substituida a virgula por ponto para que seja inserido no banco corretamente.

Alguém pode me ajudar?

Verifiquei em alguns post mas não consegui fazer.

O meu código é o seguinte:

Gostaria que alguém informasse onde e como colocar o replace.

Fico grato.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.Expires = 0%>
<!--#include file="connections/seguranc.asp" -->
<!--#include file="connections/lib_conexao.asp" -->
<!--#include file="Connections/data&hora.asp" -->
<!--#include file="connections/titulo.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "frmMain") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_lib_conexao_STRING
    MM_editCmd.CommandText = "INSERT INTO boleto (cod_cliente, fantasia, num_doc, dt_doc, nosso_num, dt_venc, valor, mens1, mens2, mens3) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("cod_cliente"), Request.Form("cod_cliente"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 70, Request.Form("fantasia")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("num_doc")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("dt_doc")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 8, Request.Form("nosso_num")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 50, Request.Form("dt_venc")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 5, 1, -1, MM_IIF(Request.Form("valor"), Request.Form("valor"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 255, Request.Form("mens1")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("mens2")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("mens3")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "CadTit.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<%
Dim controle
Dim controle_cmd
Dim controle_numRows

Set controle_cmd = Server.CreateObject ("ADODB.Command")
controle_cmd.ActiveConnection = MM_lib_conexao_STRING
controle_cmd.CommandText = "SELECT nosso_num, num_doc FROM boleto order by num_doc desc" 
controle_cmd.Prepared = true

Set controle = controle_cmd.Execute
controle_numRows = 0
%>
<%
Dim cedente
Dim cedente_cmd
Dim cedente_numRows

Set cedente_cmd = Server.CreateObject ("ADODB.Command")
cedente_cmd.ActiveConnection = MM_lib_conexao_STRING
cedente_cmd.CommandText = "SELECT * FROM cedente" 
cedente_cmd.Prepared = true

Set cedente = cedente_cmd.Execute
cedente_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%Response.Write titulo%></title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
&lt;script type="text/javascript" src="date/jquery.js"></script>
&lt;script type="text/javascript" src="date/datePicker.js"></script>
<link href="date/datepicker.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="date/styles.css">
&lt;script type="text/javascript" src="js/java.js"></script>
</head>
<body>
<!--#include file="Menu.asp" -->

<form name="frmMain" id="frmMain" method="POST" action="<%=MM_editAction%>" onSubmit="return validaForm(this)">
  <label></label>
  <table width="730" border="0" align="center" cellpadding="0" cellspacing="1" class="tabcadastro">
    <tr>
      <td colspan="4"><div align="right"><strong>Cob Itaú 2.0</strong></div></td>
    </tr>
    <tr>
      <td colspan="4" class="barra">Cedente</td>
    </tr>
    <tr>
      <td colspan="4"><input name="cedente" type="text" disabled="disabled" class="form" id="cedente" value="<%=(cedente.Fields.Item("nome").Value)%>   <%=(cedente.Fields.Item("agencia").Value)%>/<%=(cedente.Fields.Item("conta").Value)%>-<%=(cedente.Fields.Item("dv").Value)%>   Carteira:<%=(cedente.Fields.Item("carteira").Value)%>" readonly="true" /></td>
    </tr>
    <tr>
      <td colspan="3" class="barra">Nome do Sacado</td>
      <td class="barra"> </td>
    </tr>
    <tr>
      <td colspan="4"><select name="nome_rzsocial" class="form_textarea" id="nome_rzsocial" onchange="sel_nome();">
        <option value="0" selected="selected">Selecione um Sacado</option>
        <%
sql = "SELECT cod, fantasia, nome_rzsocial FROM cliente order by nome_rzsocial"
set oRS = oConn.execute(sql)
while not oRS.EOF
%>
        <option value="<%Response.Write(oRS(0) & " - " & oRS(1))%>"><%=oRS(2)%> </option>
        <%      
oRS.MoveNext
wend
oRS.close
set oRS = nothing                            
%>
      </select>     </td>
    </tr>
&lt;script>
function sel_nome()
{
var arr = new String(frmMain.nome_rzsocial.value);
arr = arr.split(' - ');
frmMain.cod_cliente.value = arr[0];
frmMain.fantasia.value = arr[1];
}
</script> 
    <tr>
      <td class="barra">Código</td>
      <td colspan="3" class="barra">Nome Fantasia</td>
    </tr>
    <tr>
      <td><label>
        <input name="cod_cliente" type="text" class="numdoc_nn" id="cod_cliente" maxlength="6" readonly="true" wmsg="Selecione o nome do sacado" />
      </label></td>
      <td colspan="3"><input name="fantasia" type="text" id="fantasia" size="92" readonly="true" wmsg="Selecione o nome do sacado"/></td>
    </tr>
    <tr>
      <td height="40" colspan="4"> </td>
    </tr>
    <tr>
      <td class="barra">Numero do Documento</td>
      <td class="barra">Data do Documento</td>
      <td class="barra">Nosso Numero</td>
      <td class="barra">Data do Vencimento</td>
    </tr>
    <tr>
      <td><input name="num_doc" type="text" id="num_doc" value="<%=(controle.Fields.Item("num_doc").Value)+1%>" maxlength="6" onclick="this.value='';" /></td>
      <td><input name="dt_doc" type="text" id="dt_doc" value="<%Response.Write FormatoData("dd/mm/aaaa")%>" onclick="this.value='';" /></td>
      <td><input name="nosso_num" type="text" id="nosso_num" value="<%=(controle.Fields.Item("nosso_num").Value)+1%>" maxlength="8" onclick="this.value='';" /></td>
      <td><input type="text" name="dt_venc" id="dt_venc" wmsg="Informe a data do vencimento" onclick="this.value='';" /></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td class="barra">Valor ( R$ )</td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><input type="text" name="valor" id="valor" onkeypress="return(MascaraMoeda(this,'.',',',event))" onclick="this.value='';" wmsg="Informe o valor do título"/></td>
    </tr>
    <tr>
      <td colspan="3" class="barra">Instrução para impressão do bloqueto<br />
         
      Todas as informações são de responsabilidade exclusiva da empresa</td>
      <td> </td>
    </tr>
    <tr>
      <td colspan="3"><table width="100" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><input name="mens1" type="text" id="mens1" size="93" onkeypress="return verifica(event);"/></td>
        </tr>
        <tr>
          <td><input name="mens2" type="text" id="mens2" size="93" onkeypress="return verifica(event);"/></td>
        </tr>
        <tr>
          <td><input name="mens3" type="text" id="mens3" size="93" onkeypress="return verifica(event);"/></td>
        </tr>
      </table>      </td>
      <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><INPUT name="Submit" TYPE="submit" class="button" Value="Confirmar")>

</td>
        </tr>
        <tr>
          <td><input name="button2" type="button" class="button" id="button2" value="Visualisar" /></td>
        </tr>
        <tr>
          <td><input type="button" class="button" onclick="window.location = 'Default.asp';" value="Sair" /></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td colspan="4" class="barra"> </td>
    </tr>
  </table>
  <label></label>
  <tr>
    <input type="hidden" name="MM_insert" value="frmMain" />
</form>
</body>
</html>
<%
controle.Close()
Set controle = Nothing
%>
<%
cedente.Close()
Set cedente = Nothing
%>

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...