Page 1 of 1

how to get the value of selected date?

PostPosted: Wed Sep 19, 2012 4:21 pm
by sssscooter
hi ,
i have a form like that
Code: Select all
<form action="" method="POST" id="form0">
                 <input type="text" name="date0" class="tcal" value="the_value_here" readonly="readonly" /><br />
                 <input type="image"  src="/submit.png" onclick =" return displayv()" />
             
                  <input type="hidden" name="submit0" value="the value_here" />
            </form>

the_value_here im wondering what it will be , so if the user selected date , then this value will be the date selected . I have used isset and $_POST but those are only when submitting the form and after it checks , but me i want to check it before submitting in javascript . to see if its null or not.
so what will be the value there please ?
i have so long this in my javascript
Code: Select all
  if (  "<?php $_POST['submit0']; ?>" == "" )
but it always null . because its not checked , it comes from jabascript code.
any help pls

Re: how to get the value of selected date?

PostPosted: Wed Sep 19, 2012 9:17 pm
by tigra
Seems like you're a bit confused with what code runs in the browser and what runs on the server.

Say you have:

Code: Select all
<form name="formname" ... >
<input type="text" name="inputname" value="blahblah" />
</form>


To read the value of the text or hidden input with JavaScript you do:

Code: Select all
<script>
var s_value = document.forms['formname'].elements['inputname'].value;
alert(s_value);
</script>


alternatively:

Code: Select all
<form name="formname" ... >
<input type="text" name="inputname" id="inputid" value="blahblah" />
</form>

<script>
var e_input = document.getElementById('inputid');
var e_value = e_input.value;
</script>

Re: how to get the value of selected date?

PostPosted: Fri Sep 21, 2012 7:36 am
by sssscooter
thx , its that what i want . it helped :)