Click to See Complete Forum and Search --> : Textbox name error


keny
04-15-2003, 03:04 PM
//Below is my code:
function myfun(temp) {

}

<form name=myform>
<input type="text" name="test_3_2233/345" size="4" value="0" />
<input type=button name=test value=test onclick="myfun('test_3_2233/345');">
</form>

//''''''''''''''''''''''''''''''''''''''''''''''''''''
It gives me error when i run the code and I think its because of the text box name.Is there any work around.I want my textbox name to be in that format only.

AdamGundry
04-15-2003, 03:06 PM
Try this:
document.getElementById(temp).value = 2;

Adam

keny
04-15-2003, 03:21 PM
Thanks That worked :)

khalidali63
04-15-2003, 03:33 PM
1. First of all you have a forward slash in the name of the element,thats wrong.its better you had an underscore there.
2. Second document.getElementById can only work when the element does have an id attribute,
and if it worked then its a "fluke" and this can only happen in IE.

If you change the name of the element to
test_3_2233_345

then your exisitng code will work,and if you want to use document.getElementById then you have to set an id attribute in the input element

:D

Cheers

Khalid

keny
04-22-2003, 02:30 PM
First and last thing " Khalidali63 " is that when I said that my textbox name cannot change you suggest me to put underscore..........what kind of solution is that.
If i change the name to test_3_2233_345 I KNOW MY CODE WORKs.

Thanks anywaz

khalidali63
04-22-2003, 02:55 PM
:p
shhhh..overlooked...
the rest remains valid though,to use getElementById the element has to be assigned an id attribute.
:D