PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



elements array

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> Java Script / AJAX
View previous topic :: View next topic  
Author Message
YWH



Joined: 09 Mar 2007
Posts: 8

PostPosted: Wed Sep 03, 2008 3:40 pm    Post subject: elements array Reply with quote

I am adding calendar right next to my date field in a form.
It only works for selecting one record at a time.
Before I added the calendar, it works for selecting multiple records.
what's wrong with my javascript correct ?
Thanks for any help.

.....my date field display in a table with in a form......
if ($result && mysql_num_rows($result)) {
while($query = mysql_fetch_array($result)) {
.
.
'|<input type="text" size="10" name="checkin_dates[]" value="'.$query['ro_checkin'].'" readonly="readonly"><a href="javascript:cal6.popup();"><img src="images/calendar/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>'.
.
.
} }

......script after the </form>......
echo '<script language="JavaScript">'.
'var cal6 = new calendar3(document.forms[\'userform\'].elements[\'checkin_dates[]\']);'.
'cal6.year_scroll = false;'.
'cal6.time_comp = false;'.
'</script>';

I am not sure if elements[\'checkin_dates[]\'] is the correct syntax. It works for submitting one record, but not multiple records.
Back to top
View user's profile Send private message
YWH



Joined: 09 Mar 2007
Posts: 8

PostPosted: Thu Sep 18, 2008 5:01 pm    Post subject: reset/clear calendar entry Reply with quote

I was able to have the multiple calendar object work within a form (from last post). Now I want to reset/clear each individual calendar input within a form. The reset() resets all the dates in the form. How can I clear just one calendar input at a time. I had tried different code to clear one element, but didn't work. Thank you for any help.

echo "<form name='userform' method='POST' action='checkin.php'>";
$rows=0;
//table code starts here, but not showing...
if ($result && mysql_num_rows($result)) {
while($query = mysql_fetch_array($result)) {
.
.
$query['name'].'|'.
'|<input type="text" size="10" id='.$rows.' name="checkin_dates['.$rows.']" value="'.$query['ro_checkin'].'" readonly="readonly"><a href="javascript:cal'.$rows.'.popup();"><img src="images/calendar/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><img src="images/calendar/reset.gif" onclick=javascript:reset()>'.
$query['ro_transmit']);

$rows++;
}
}
//table ends here
echo "</form>";

for ($i=0; $i<$rows; $i++) {
echo '<script language="JavaScript">'.
'var cal'.$i.' = new calendar3(document.forms\'userform\'].elements[\'checkin_dates['.$i.']\']);'.
'cal'.$i.'.year_scroll = false;'.
'cal'.$i.'.time_comp = false;'.
'</script>';
}
Back to top
View user's profile Send private message
YWH



Joined: 09 Mar 2007
Posts: 8

PostPosted: Thu Sep 18, 2008 8:33 pm    Post subject: Reply with quote

I got it to work.

'|<input type="text" size="10" id='.$rows.' name="checkin_dates['.$rows.']" value="'.$query['ro_checkin'].'" readonly="readonly"><a href="javascript:cal'.$rows.'.popup();"><img src="images/calendar/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a> <img src="images/calendar/reset.gif" onclick="document.getElementById(\''.$rows.'\').value=\'\'">'.
Back to top
View user's profile Send private message
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



PHP Code Examples
 Stream diffrent sizes of images from a single image to save disk space.
 JavaScript dropdown list menu to switch any page.
 Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
 PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
 Link Extractor - This function is used to extract links from a given URL. This will convert relative path into absolute path and also remove PHPSESSID stuff.
 Building a Dynamic Form using Javascript and innerHTML. Add form elements in realtime without refreshing the page.
 A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Post new topic   Reply to topic    WeberForums.com Forum Index -> Java Script / AJAX All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum