SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot DonTino's Avatar
    Join Date
    Nov 2001
    Location
    Germany
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting javascript variable into php form

    Hello all,

    I'm not a Javascript expert and need some help.

    I have a Flash Map that uses some Javascript code to display some data from the flash app in a browser message alert. This is the code:

    Code:
    <script language="javascript">
    	function xmlDispatcher(xml){
    		alert("flash sent :" + xml);
    			}
    </script>
    Now how can I make it so that the data is not only displayed in an alert but put into a form??
    That way I can use the data and use it in a regular php form to work with them.

    Ideas and help are very appreciated. Like I said I'm not a JavaScript expert.

    thanks a lot

    Tino
    Discover the Divine Truth - NOW blogging
    tino-designs.com integrates the usability of the internet
    with the illustration and style of design

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give the target element an ID like this:

    Code html4strict:
    <p id="xml"></p>

    Then something like this should do the trick:

    Code JavaScript:
    function xmlDispatcher(xml){
        var elementID = 'xml';
        document.getElementById(elementID).appendChild(document.createTextNode("flash sent :" + xml));
    }
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Zealot DonTino's Avatar
    Join Date
    Nov 2001
    Location
    Germany
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jimmy thanks a lot,

    that way I can get the data displayed on the website but how can I get it into an form element??

    i.e.:
    <input type=text name="fieldname" value="data to be displayed or inserted here">

    I just can't figure it out.

    Thanks a lot.

    Tino
    Discover the Divine Truth - NOW blogging
    tino-designs.com integrates the usability of the internet
    with the illustration and style of design

  4. #4
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh right...

    Like this:

    Code JavaScript:
    function xmlDispatcher(xml){
        var elementID = 'xml'; // The ID of the input element
        document.getElementById(elementID).value = "flash sent :" + xml;
    }

    Code html4strict:
    <input type=text name="fieldname" id="xml" value="data to be displayed or inserted here">
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  5. #5
    SitePoint Zealot DonTino's Avatar
    Join Date
    Nov 2001
    Location
    Germany
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works pefectly now thanks a lot

    Tino
    Discover the Divine Truth - NOW blogging
    tino-designs.com integrates the usability of the internet
    with the illustration and style of design


Bookmarks

Posting Permissions

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