Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a form value without hitting the submit but

Status
Not open for further replies.

otgriffin

Programmer
Jan 21, 2003
8
US
Hello,

I am building a survey and I need to disable certain form elements when a selection is made in a radiobutton group. I am using Php and mysql. I have written a function in javascript that I thought would disable the needed elements but it will not. Here is the javascript code:

function disable_enable(){
if(document.survey.tspdata.value=="Vector"){
document.survey.GeoTIFF.disabled=true;
document.survey.ESRI_BIL.disabled=true;
document.survey.ASCII_Grid.disabled=true;
document.survey.ENVI.disabled=true;
document.survey.ERDAS.disabled=true;
document.survey.PCI.disabled=true;
document.survey.Tiff_tfw.disabled=true;
}else if(document.survey.tspdata.value=="Raster"){
document.survey.ESRI_GeoData_Base.disabled=true;
document.survey.ESRI_shape.disabled=true;
document.survey.ESRI.e00.disabled=true;
document.survey.DXF.disabled=true;
document.survey.DWG.disabled=true;
document.survey.DGN.disabled=true;
document.survey.Intergraph_GeoMedia_Access_Warehouse.disabled=true;
document.survey.Intergraph_Microstation.disabled=true;
document.survey.MapInfo_Tab.disabled=true;
document.survey.MapInfo_Mif_Mid.disabled=true;
}
}

//end of code
I call this in my html code as : <input name=&quot;tspdata&quot; type=&quot;radio&quot; value=&quot;Vector&quot; onSelect=&quot;disable_enable()&quot;>

It seems to me that the script is not obtaining the value in the field tspdata. I was wondering if I need to pass the value to my url, but the problem with this is that I don't want to hit the submit button to do so. When I hit the submit button I want to make an insert into a database. Can someone please enlighten me on what is going on and then help me correct this problem.

Thank you in advance!
 
try the javascript forum, they can probably answer this in a couple seconds for you.
 
radio buttons are a bit dodgy in Javascript.

They are stored in an array with the value inaccessible until the form is posted.

However, you can use:

if(document.survey.tspdata[0].checked==true){

if it's not the first radiobutton with the name tspdata, change the array index accoringly. ie, forth button is tspdata[3]
 
Marklar,

Thank you for your advice. I am sure this will work, but I had already solved the problem by using two sperate functions and then I called onPropertyChange=&quot;my_function()&quot; in my input tag. This seems to work like I wanted it to. I am defintely sure that I will be using your idea on other projects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top