• 0
Sign in to follow this  
fantasma

trocar

Question

trocar as 3 primeiras letras do name dos input's

<input type="text" name ="aaa_1" >
<input type="text" name ="aaa_2" >
<input type="text" name ="aaa_3" >
<input type="text" name ="aaa_4" >

Edited by fercosmig
Adicionar tag CODE

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

vou explicar melhor

quero colocar um prefixo na atraz do valor da name, em todas as caixas de texto

ex;

<input type="text" id="teste" name="x"/>
ficaria
<input type="text" id="teste" name="mar_x"/>
<script language="javascript" type="text/javascript">
<!--
function testa(){
    alert(document.getElementById('teste').name);
    document.getElementById('teste').name = 'y';
    alert(document.getElementById('teste').name);
}
-->
</script>
<input type="text" id="teste" name="x"/>
<input type="text1" id="teste" name="x"/>
<input type="text2" id="teste" name="x"/>
<input type="button" onClick="testa();"/>

Edited by fercosmig
Adicionar tag CODE

Share this post


Link to post
Share on other sites
  • 0

testa ae boi, ve se issoa ae

function muda(par){
    obj = document.getElementById(par);
    alert(obj.name);
    obj.name = 'mar_' + obj.name;
    alert(obj.name);
}
<input type="text" name="texto" id="txt1">
<input type="button" onClick="muda('txt1');"/>

Share this post


Link to post
Share on other sites
  • 0

E ai beleza boi ......mas se eu tiver varios inputs, em tenho que colocar 'mar' em todos os input's.............valeu boi bom final de semana e muita pinga...hahahahaha

<input type="text" id="teste" name="x"/>
<input type="text1" id="teste" name="x"/>
<input type="text2" id="teste" name="x"/>
<input type="button" />

Share this post


Link to post
Share on other sites
  • 0

boi, não testei.. nem sei se é assim ahaa

mas testa ae

function muda(){
    obj = document.getElementsByTagName('input');
    alert(obj.length);
    for(i = 0; i < obj.length; i++){
        alert(obj[i].Name);
        obj[i].Name = 'mar_' + obj[i].Name;
        alert(obj[i].Name);
    }
}

no exemplo vai mudar o nome do botão tb

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this