Pop up window details to update parent details

Dear Paul,
How will the script look like because I dont find any relevant sample as per your suggestion?

The parent script would just use document.getElementById() with the id that’s passed to the function, to update it with the value that’s also passed to the same function.

Dear Paul,
Is this how you meant? But to call this function for now I have kept it in the parent window. So you said call from the child how to call it ?

function updateValue(tyreID,val)
{
var mySelect = document.getElementById(tyreID);
mySelect.value=val;
}

In the same way that you have made other calls to the parent window.

window.opener.updateValue(…, …)

Dear Paul,
But can my codes change the select word the val based on the checkbox selected. Thank you.

The child can pass whatever information is needed to the parent, and the parent can make whatever changes you need to make.

Dear Paul,
I manage to solve all the relevant problem. Now I got a next problem where I need to post this form and I must make sure now the all the select are replace with the tyre serial and also how am I going to capture the post value as there all will be dynamic? Any idea?

You could use form inputs to store the values, so that they are then submitted with the form. If you don’t want them to be displayed, use hidden inputs.

Dear Paul,
The problem each time you pick a different layout you will get different number of tyres. So how to capture in the php post? Because I cant put like this $RI1L=$_POST[‘RI1L’]; because each has different number of tyres.

You could give the form field a name such as “tyre[‘RI1L’]” so that PHP just needs to get the submitted tyre array, and loop through the keys in that array,

Dear Paul,
I am not quite clear with your solution. Say I first I got only 4 tyre so I have row1 tyre[‘F1L’],tyre[‘F1R’] , row2 tyre[‘R1L’],tyre[‘R1R’]. Second one I got row1 tyre[‘F1L’],tyre[‘F1R’] , row2 tyre[‘R1L’],tyre[‘R1R’], row3 tyre[‘R2L’],tyre[‘R2R’]. So how on the php I should capture it based on this two example? In php I can have this $tyre= (array) $_POST[tyre]; right.

You don’t need to cast it as an array because the field names already ensures that it is an array.

You can then use standard PHP techniques to process the array, for example:


foreach ($tyre as $wheel => $type) {
    ...
}

But that’s diverging quite strongly from the intention of this forum, to help people with JavaScript coding.
The people in the PHP forum will be better placed to give PHP-based solutions for you.

Dear Paul,
Ok I will post it over on php. Another question on javascript side. How am I going to validate this form based on each different layout where each of the select must have tyreID and also must be different?

You can attach a function to the onsubmit event of the form, which could check that you have no links left in there, and other conditions that must be met.

Failure to meet any condition can result in false being returned from the function, which cancels the submit event.

Dear Paul,
IS it that is must be something like this.

var elem = document.getElementById(‘frmMain’).elements;
for(var i = 0; i < elem.length; i++)
{

     }

Nope, it’s where you assign to the onsubmit event of the form a function that performs the validation checks that you require.

Dear Paul,
Yes first I have this line to make the form
<form action=“<?=$_SERVER[‘PHP_SELF’]?>” method=“post” name=“form1” id=form1 onSubmit=“return validateForm();”>. I would like to ask you opinion if it is a table where to best put the form element in a tr or td? Then next I have my function as below for the onSubmit.

function validateForm()
{
var elem = document.getElementById(‘form1’).elements;
for(var i = 0; i < elem.length; i++)
{

}

}

Your requirements are quite peculiar from the standard form validation techniques.

I presume that the first thing you’ll need to check is if any of the links to select a tyre are still there. If there are any, the form shouldn’t be submitted, right?

Dear Paul,
Yes you are right if it is still select dont allow is to be submitted. So where to put extra control then?

If you replace the link text with the choice that they made, then one of the checks could be to get a collection of links from the appropriate section. If any of them have the select text, the form should not yet be submitted.