Passing long strings back via submitting form

  • Thread starter Thread starter Bes
  • Start date Start date

Bes

Bes

Soldato
Joined
18 Oct 2002
Posts
7,318
Location
Melbourne
Hi,

I have a php script which is invoked by javascript´s getElementbyID. This means I am passing the values the script needs back in using vars tacked on to the URL - eg. script.php?thing1=something&thing2=something2

Now, this is OK unless I want to pass a really long string back to the script... How can I do this without refreshing the page/ submitting the form? I am thinking of using a text file as a temporary holding place (eg getting the javascript to write the string to it), and then having the PHP read this string out.

Is there a better way of doing it? (Remember I cannot submit the page, so cannot just pass it back to php unless I can somehow invoke some PHP without actually submitting the page)?

Thanks
 
Hey, great thanks that's exactly what I need! My site uses JQuery anyway so I am using that.

My next question is this:

I don't know how many elements will be in my form, as all the page's data is in a DB so I need to come up with a way to tell JQuery to ensure it always has the ability to handle/ post all the elements in the form.... What is the best way to post n elements back to my back end script, whether there are 2 elements or 20 elements in my form?

This is the closest I can get, which lists just the first element it comes across:

PHP:
  <script>
  $(document).ready(function(){
  
   var input= $("input[name^='alteration']");
   
   var multipleValues = $("input[name^='alteration']").val();
   $("div").text("For this type jQuery found " + input.length + "." + multipleValues);

    
	
  });
  </script>
	</head>
<body>
	<form id="login_form" method="post">
		<p>Username: <input type="text" id="alteration1" name="alteration1" value="ww"/></p>
		<p>Password: <input type="text" id="alteration2" name="alteration2" value="xx"/></p>

Any ideas?

Thanks
 
Last edited:
Back
Top Bottom