Jump to content

Recommended Posts

I am a PHP guy struggling with JS.

 

I dynamically create forms with several fields that can change names at any time.  I need to gather all form input names and values into a string that I can then send in one $_GET element?  I will separate them out again in the PHP that receives the $_GET element.

 

Here is the section of my code giving me trouble. I simplified to reduce the possibility of masking one problem with another.

 

<html>
<head>
<title>FD Manual</title>
<script src="http://train.iaff106.org/js/scriptaculous/prototype.js" type="text/javascript"></script> 
<script src="http://train.iaff106.org/js/scriptaculous/scriptaculous.js" type="text/javascript"></script>

<script type="text/javascript">
NewSlidePreviewRequest = function (typeid)
{
	var newdata = $('S').serialize(true);
	alert(newdata);

	var jsonstr= JSON.stringify(newdata);	
	alert(jsonstr);
                // AJAX stuff sends string to PHP receiver for parsing and response
}
</script>
</head>

<body>
<form id="S">
<label for="ImgTopCaption">Image Top Caption</label>
<input type="text" id="ImgTopCaption" value="Image Top Caption">

<label for="Text">Text</label>
<textarea id="Text">This is my text</textarea>

<a href="#" onclick="NewSlidePreviewRequest(1)" >Click HERE</a>
</form>

</body>
</html>

 

I was expecting one of those alerts to contain a string like:

{ImgTopCaption: 'Image Top Caption', Text: 'This is my text'}

 

But not working like I hoped.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.