Using this code I disable my submit button on the initial load. I'd like to enable it when the form is valid. I have Prototype.js on my system.

I send back a chunck of html to update my target. Is it possible to send back an id so that I can check that and enable my button?

Or how best should I accomplish this? As you will see I don't know what I'm doing! The real questions for me are in red.

Ajax code ...

<script type="text/javascript">        

    function run_ajax() {
         var url = '/cgidev2p/r_chgpwd.pgm';
         var pars = 'v_current='+escape($F('v_current'))+ '&v_new=' + escape($F('v_new')) + '&v_confirm=' + escape($F('v_confirm')) + '&sessionid=' + escape($F('sessionid'));
         var target = 'v_messege';
         var myAjax = new Ajax.Updater(target, url, {method:'get', parameters:pars});

	 if (!document.getElementById('success')) return;  {
		var submitObj = document.getElementById('goButton');
		submitObj.disabled = false;
	 }		 
    }
	
	function init() {
		if (!document.getElementById) return;
		var submitObj = $('goButton');
		submitObj.disabled = true;
	}
	
</script>
<body onload="init()">

Target ...

<div id="v_messege"></div>

Here's the code I send back if the form is valid ...

<div align="left" class="ct26" style="padding-left:5px; width:350px" id="success">
   <div class="wraptocenter"><img src="/images/common/check.gif" width="16" height="14">&nbsp;&nbsp;&nbsp;/%info_note%/</div>
</div>

Wth 80 views and 0 replies I'm wondering ...

Is my question stupid?

Did I ask it in a way that doesn't make sense? I do that often.

Is what I'm trying to accomplish not possible or a real PITA?

yes, I have the same situation, where in I have enable a button through javascript in VB.NET. Surprised that none replied.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.