I"ve been having a little problem with a form I’ve been putting together in php. I’ve got another post regarding this. But I realized that I could probably solve this all with the use of javascript.
Basically the only problem I have right now is that I have more than one input field with the same name, so I need to dynamically change this. As it’s worked out, I already have some javascript in place that I believe I can piggyback on to accomplish this. I just haven’t been able to find a way that would work in this context, most solutions I’ve found deal with jquery, which this site does not currently have.
So here’s the code that I have in place:
<script type="text/javascript">
function rad1()
{
document.getElementById("check1").style.visibility="visible"
document.getElementById("check2").style.visibility="hidden"
document.getElementById("check3").style.visibility="hidden"
document.getElementById("check4").style.visibility="hidden"
}
</script>
<td style="padding-left: 15px;"><input id="radio" type="radio" name="refer_btn" value="A Friend" onclick="rad1()" /></td>
<td><span id="check1">You're friend's name?:<input type="textfield" name="refer_box" id="text1" value=""/></span></td>
It currenty shows the textfield if the radio button is clicked. I have this at a larger scale in with the form and javascript.
Now, I believe that there’s gotta be some way to add the name change commands in this function as well. Something like:
function rad1()
{
document.getElementById("check1").style.visibility="visible"
document.getElementById("check2").style.visibility="hidden"
document.getElementById("check3").style.visibility="hidden"
document.getElementById("check4").style.visibility="hidden"
document.getElementById("text1").obj.name ="refer_box"
document.getElementById("text2").obj.name ="null"
document.getElementById("text3").obj.name ="null"
document.getElementById("text4").obj.name ="null"
}
Obviously that doesn’t work, but this should just be a matter of using the wrong verbaige, right?
Re: Wow! it appears that this works. Could have sworn I tried that already.
document.getElementById(“text1”).name =“refer_box”