Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to convert javascript to php coding

    Hi guys,
    Plz help me ("urgent...deadline tomorrow!")

    <form>
    <select onChange="updatecalendar(this.options)">
    <script type="text/javascript">

    var themonths=['January','February','March','April','May','June',
    'July','August','September','October','November','December']

    var todaydate=new Date()
    var curmonth=todaydate.getMonth()+1 //get current month (1-12)
    var curyear=todaydate.getFullYear() //get current year

    function updatecalendar(theselection){
    var themonth=parseInt(theselection[theselection.selectedIndex].value)+1
    var calendarstr=buildCal(themonth, curyear, "main", "month", "daysofweek", "days", 0)
    if (document.getElementById)
    document.getElementById("calendarspace").innerHTML=calendarstr
    }

    document.write('<option value="'+(curmonth-1)+'" selected="yes">Current Month</option>')
    for (i=0; i<12; i++) //display option for 12 months of the year
    document.write('<option value="'+i+'">'+themonths[i]+' '+curyear+'</option>')


    </script>
    </select>

    <div id="calendarspace">
    <script>
    //write out current month's calendar to start
    document.write(buildCal(curmonth, curyear, "main", "month", "daysofweek", "days", 0))
    </script>
    </div>

    </form>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    And what exactly is your question? PHP is a server side language, you cannot just convert javascript over to it directly; JS is an event driven language which in web based PHP there is no way to capture (ie: no onchange).
    So the only thing PHP can do above is create the select.
    PHP Code:
    $aMonths = array('January''February''March', ...);
    print 
    '<select>';
    foreach (
    $aMonths AS $key => $month)
    {
        
    printf('<option value="%d">%s</option>'$key$month);
    }
    print 
    '</select>'

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    And what exactly is your question? PHP is a server side language, you cannot just convert javascript over to it directly; JS is an event driven language which in web based PHP there is no way to capture (ie: no onchange).
    So the only thing PHP can do above is create the select.
    PHP Code:
    $aMonths = array('January''February''March', ...);
    print 
    '<select>';
    foreach (
    $aMonths AS $key => $month)
    {
        
    printf('<option value="%d">%s</option>'$key$month);
    }
    print 
    '</select>'
    Hi,

    I need server side code.my website developing php with symbony frame work.
    i created monthly calender.i need code for monthly calender creation.

    plz hel me.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by vijayram View Post
    Hi,

    I need server side code.my website developing php with symbony frame work.
    i created monthly calender.i need code for monthly calender creation.

    plz hel me.
    Did you try the posted code?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •