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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reaload Page Using Form Field as Variable!

Status
Not open for further replies.

RPGguy

Programmer
Jul 27, 2001
73
US
This page shows data with an mySQL select based on a date. The default date is 'today' (and works fine) but the user can change the date via a pop up calendar. I need to have the page reload and execute the SQL select using the new date. The form piece of the script is:

<form method=&quot;POST&quot; onsubmit=&quot;schedulepage.html?asof=<? print $asof ?>&quot;>
<INPUT name=asof value=&quot;<? print $asof; ?>&quot; type=&quot;hidden&quot;>
<font size=&quot;1&quot;>
<INPUT onclick=&quot;fPopCalendar(asof,asof); return false;&quot; type=submit id=button1 name=button1 value=&quot; ? &quot; ; ></font></td>

</form>

I hoped that by making the &quot; ? &quot; type=submit the calendar would popup (that's the function shown) and then reload itself passing the chosen date (asof). When I click the calendar and select a date nothing happens. I'm sure this is pretty basic but I searched Tek-Tips and didn't find the answer.
I'm using HTML, PHP, mySQL and JavaScript.

I just tried removing the 'return=false' as an experiment (I really don't understand its' purpose yet). The page redisplayed in a new window with the calendar behind it. I closed the window and picked a date on the calendar. Another window popped up again this time showing the new date with the correct data displayed! It seems the problem is there somewhere so maybe someone can pin point it.

Thanks to all for their help.

Scott
 
i'm guessing the fPopCalendar changes the value of the hidden field &quot;asof&quot;? if so, i would try changing button1 to a type=&quot;button&quot;, and then modify fPopCalendar to submit the form after updating the hidden value.

&quot;return false&quot; is used in this type of situation to cancel the normal action - in this case it would prevent form submission by the submit button. it's not necessary to use a submit for your purpose though


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Jeff,
Thanks for the quick reply. The function does change the value of 'asof'. I think I understand what you are suggesting but the fpopCalendar is used in many of my scripts so I don't think I want to modify to do this specifically.

I have just been reading up on 'Modal dialog' which, if I understand, stops processing until the modal window is addressed. Sounds like what I'm looking for. If this is correct can someone please give me an examle where the modal window is a function and not an HTML file? The function will pop up my calendar and return the value in 'asof.
 
i'm not sure if showModalDialog will accept anything other than a file as its source...check on msdn

furthermore, showModalDialog is for IE only. NS/Mozilla has its own version, and i don't know anything about Opera or Safari etc

since javascript function arguments are optional, modifying your function is possible without affecting other existing implementations of it by adding a new third arg. something like so should work:
<script>
function fPopCalendar (oldArg1, oldArg2, newOnReturnArg) {
var onreturn = newOnReturnArg ? newOnReturnArg : null;

// existing code...

if (onreturn) onreturn();
}
</script>

<input type=&quot;button&quot; value=&quot; ? &quot; fPopCalendar(asof, asof, this.form.submit);&quot; />

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top