显示文本字段的值 [英] show value of textfield
问题描述
Hello All
我有一个脚本,我需要在另一个textfield / field中显示文本字段的值。我已经用我的单选按钮做了同样的事情并选择了这样的字段:
[HTML]< script type =" text / javascript">
功能检查(图层){
document.forms [0] .answer.value = layers
}
函数PrintValues ()$
var myString = document.mainform.file.value
var myStringLength = myString.length
var Comma = myString.lastIndexOf('','')
var SufNumChars =逗号+ 1
document.mainform.result.value =('''') ;
for(i = 0; i<逗号; i ++)
document.mainform.result.value + =(myString.charAt(i));
document.mainform.result.value + =('''');
for(i = SufNumChars; i< myStringLength; i ++ )
document.mainform.result.value + =(myString.charAt(i));
}
< / script>
< div class =" Accord ionPanelContent">
< input name =" layers"值= QUOT; 2英寸类型= QUOT;无线电"的onclick = QUOT;检查(THIS.VALUE)" /> 2< br />
< input name =" layers"类型= QUOT;无线电"的onclick = QUOT;检查(THIS.VALUE)" /> 4< br />
< input name =" layers"类型= QUOT;无线电"的onclick = QUOT;检查(THIS.VALUE)"值= QUOT; 6英寸/> 6< br />
< input name =" layers"类型= QUOT;无线电"的onclick = QUOT;检查(THIS.VALUE)"值= QUOT; 8英寸/> 8
< / div>
< input type =" text"名称= QUOT;答案"大小= QUOT; 5英寸readonly =" readonly">
< div class =" AccordionPanelContent">
< select name =" file"大小= QUOT 1 QUOT;平变化= QUOT;函数printValues();" target =" _parent._top"
onmouseclick =" this.focus()">
< option value =" DHL">运送DHL< / option>
< option value =" UPS">运送UPS< / option>
< / select>
<输入名称="结果">
< / div>
[/ HTML]
但我似乎无法弄清楚如何使用文本字段来完成此操作。任何人都可以帮我这个... ???
祝你好运
Hello All
I have a script where i need to show the value of a text field in another textfield/field. I have done the same with my radio buttons and select fields like this:
[HTML]<script type="text/javascript">
function check(layers){
document.forms[0].answer.value=layers
}
function PrintValues(){
var myString = document.mainform.file.value
var myStringLength = myString.length
var Comma = myString.lastIndexOf('','')
var SufNumChars = Comma + 1
document.mainform.result.value=('''');
for(i=0; i<Comma; i++)
document.mainform.result.value+=(myString.charAt(i ));
document.mainform.result.value+=('' '');
for(i=SufNumChars; i<myStringLength; i++)
document.mainform.result.value+=(myString.charAt(i ));
}
</script>
<div class="AccordionPanelContent">
<input name="layers" value="2" type="radio" onclick="check(this.value)" /> 2<br />
<input name="layers" type="radio" onclick="check(this.value)" /> 4<br />
<input name="layers" type="radio" onclick="check(this.value)" value="6" /> 6<br />
<input name="layers" type="radio" onclick="check(this.value)" value="8" /> 8
</div>
<input type="text" name="answer" size="5" readonly="readonly">
<div class="AccordionPanelContent">
<select name="file" size="1" onchange="PrintValues();" target="_parent._top"
onmouseclick="this.focus()">
<option value="DHL">Ship with DHL</option>
<option value="UPS">Ship with UPS</option>
</select>
<input name="result">
</div>
[/HTML]
But i can''t seem to figure out how to do this with a textfield. Can anybody help me with this...???
Best regards
推荐答案
嗨老兄,对不起我我无法清楚地遵循您的要求,但我已经对您的代码进行了一些修改,并且它正在运行。如果你需要任何改变,请查看并发回。
[HTML]< html>
< head>
< script type =" text / javascript">
var resVal;
功能检查(图层)
{
resVal = layer;
// alert(resVal);
}
函数printThis()
{
var result;
result = resVal;
result + ="," + document.getElementById('' myAnswer'')。va lue;
var x = document.getElementById(''myFile'')。selectedIndex;
result + ="," + document。 getElementById(''myFile'')。opti ons [x] .text;
document.getElementById(''myResult'')。value = result;
}
< / script>
< / head>< body>
< form>
< ; input type =" radio"名称= QUOT;层" onclick =" check(this.value)"
value =" 2"> 2< br />
< input type =" radio" ;名称= QUOT;层" onclick =" check(this.value)"
value =" 4"> 4< br />
< input type =" radio" ;名称= QUOT;层" onclick =" check(this.value)"
value =" 6"> 6< br />
< input type =" radio" ;名称= QUOT;层" onclick =" check(this.value)"
value =" 8"> 8< br />
< br />
< input type =" text" id =" myAnswer">
< br />
< select id =" myFile">
< ;选项>运送DHL< /选项>
<选项>运送UPS< / option>
< / select>
< br />
< input type =" text" ID = QUOT; myResult" onclick =" printThis()">
< / form>
< / body>
< / html> [/ HTML]
问候
Ramanan Kalirajan
Hi Dude, I am sorry I am not able to follow your requirement clearly, but I had made some modification in ur code and it''s working. Just check it out and post back if u need any change.
[HTML]<html>
<head>
<script type="text/javascript">
var resVal;
function check(layer)
{
resVal=layer;
// alert(resVal);
}
function printThis()
{
var result;
result= resVal;
result+=","+document.getElementById(''myAnswer'').va lue;
var x = document.getElementById(''myFile'').selectedIndex;
result+=","+document.getElementById(''myFile'').opti ons[x].text;
document.getElementById(''myResult'').value=result;
}
</script>
</head><body>
<form>
<input type="radio" name="layers" onclick="check(this.value)"
value="2">2<br />
<input type="radio" name="layers" onclick="check(this.value)"
value="4">4<br />
<input type="radio" name="layers" onclick="check(this.value)"
value="6">6<br />
<input type="radio" name="layers" onclick="check(this.value)"
value="8">8<br />
<br />
<input type="text" id="myAnswer">
<br/>
<select id="myFile">
<option>Ship with DHL</option>
<option>Ship with UPS</option>
</select>
<br/>
<input type="text" id="myResult" onclick="printThis()">
</form>
</body>
</html>[/HTML]
Regards
Ramanan Kalirajan
效果很好,谢谢,但我真正需要的是一个修改javascript,以便当我在表单中使用文本字段时,文本字段的输入也将显示在另一个文本字段或< td>中。标签。
也许正在使用getelementbyid或类似的东西,但不能解决如何做到这一点......
Works great, thanks, but what i really needed was a modification of the javascript, so that when i use a textfield in the form, the input of the textfield would also show in another textfield or <td> tag.
Maybe be using getelementbyid or something like that, but can''t quit figure out how to do that......
工作得很好,谢谢,但我真正需要的是修改javascript,这样当我在表单中使用文本字段时,textfield的输入也会显示在另一个textfield或< td>标签。
也许正在使用getelementbyid或类似的东西,但不能不知道如何做到这一点......
Works great, thanks, but what i really needed was a modification of the javascript, so that when i use a textfield in the form, the input of the textfield would also show in another textfield or <td> tag.
Maybe be using getelementbyid or something like that, but can''t quit figure out how to do that......
你好,如果您在文本字段中输入一些字符,则必须将其复制到另一个文本字段中。这是否是你的要求?
问候
Ramanan Kalirajan
Hi dude, If u enter some characters in a textfield the same must be copied into another textfield. whether this is your requirement?
Regards
Ramanan Kalirajan
这篇关于显示文本字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!